*UPDATED 3/1/19* Layer Shortcuts tool

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

Hi Wes,

Oh, no! I can't believe I didn't run into this much sooner but I tried importing a complex character rig with Layer Shortcuts and the buttons stopped working. When I open the project file normally, the buttons are fine, they only break when the rig is imported. This seems to be the case in either 12.5 or 13.5.2. I'm not sure yet if the problem is unique to this rig or any rig using Layer Shortcuts.

Sigh...at home I guess I haven't been testing with Import until this week, and at work I haven't been using Layer Shortcuts, so I must have never tried these two together till now. D'oh! I hope it's this rig and it's a problem I can fix here, or if the problem is in Layer Shortcuts I hope it's not a difficult fix.

Will update later with more info and examples as I'm able to.
Last edited by Greenlaw on Sat Mar 19, 2022 1:19 am, edited 1 time in total.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

I'll have to come back to this later but here's a little more info...

After importing the rig, the rig looks normal until I try to use Layer Shortcuts (LS).

After selecting the LS tool and clicking on an LS button, the button's on-screen name changes to the parent folder's name, and the intended layer is not selected. This behavior repeats with each of button as I click on it. ATM, all of the LS buttons in my rig have the same name as the rigs' parent layer.

To be clear, LS works fine when the project is opened normally; the error occurs only after importing the rig into a project.

When I have time today, I'll post an example project that does this.
Last edited by Greenlaw on Sat Mar 19, 2022 1:22 am, edited 3 times in total.
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by synthsin75 »

Just at a quick guess, I'm thinking either the layer:ScriptData() isn't importing with the layer or the layers' unique ID (layer:UUID()) is changing. I'll have to test when I have time. If it's either, it could be a big problem trying to work around, as data the script relies on could be just being lost when importing.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

Thanks Wes. I just got home and will look into it on this end. Hope it's not as serious as it sounds...this tool is just too useful to lose. :cry:
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by synthsin75 »

Yeah, importing changes the layer's UUID, which means that the UUID stored in scriptdata no longer corresponds to the layer's new UUID.

I'll have to rethink how this can work without UUIDs.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

Thanks for looking into this Wes.

I wondered if Copy Layer/Paste Layer handled it any differently but I got same result. Bummer.
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by synthsin75 »

Greenlaw wrote: Sat Mar 19, 2022 8:28 am Thanks for looking into this Wes.

I wondered if Copy Layer/Paste Layer handled it any differently but I got same result. Bummer.
Yeah, I tried that too. Turns out the only unique layer identifier that survives import is the UUID that identifies a reference layer, but only when not imported as a reference (so it's still referencing it's original layer, instead of being an imported reference of a reference).

So right now I'm toying with the idea of the user making a reference of the group they want to import, import it, break the reference, and then delete the reference in the original file. That, or identify the layers in some way the user could accidentally delete. As it works now, the user can't break the connection without deleting the layer. Either way would require reworking the script. May take a while.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

Good luck Wes! Hope you can get this working.
User avatar
SuperSGL
Posts: 364
Joined: Wed Mar 11, 2015 2:55 am
Location: New Hampshire
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by SuperSGL »

Really liking this script! I just started using it. Decided to use the create shape version of the buttons. Works great! I can even copy and paste the first shape and create it as a separate button (I was worried they would be linked to the same layer) My favorite use is to be able to get back to the bone layer quickly and probably best to use the short cut keys for that but I also use the ovals as a swatch so If I already created that, I can just select individual shapes for the buttons. Like the body color I'll copy that and paste it and change the outline to red so I know it's the bone layer.
I saw something about Importing the characters with the buttons not working? I only imported my first into a new file and all the buttons still worked. Haven't tried it with a file that has it's own buttons already set up. Anyway Thanks Wes! this is a really cool time saver!
"Animation is not the art of drawings that move but the art of movements that are drawn."
Norman McLaren


My Animations
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

SuperSGL wrote: Wed Jun 22, 2022 1:11 am I saw something about Importing the characters with the buttons not working? I only imported my first into a new file and all the buttons still worked. Haven't tried it with a file that has it's own buttons already set up. Anyway Thanks Wes! this is a really cool time saver!
This problem occurs when you import a rig that uses Layer Shortcuts (LS) into another project. If you click on any of the buttons after import, the button will break.

FYI, it's okay if you import other files into a project using LS. For example, if you want to animate a character rig that uses LS against a different background, importing the new BG project will not break LS.

However if you import a second character that uses Layer Shortcuts, the buttons for the second character will break as soon as you try to use them. LS for the first character should still be fine since that one was never imported.

I hope Wes is able to fix this tool. LS is incredibly useful when you don't need to import it.
User avatar
Hoptoad
Posts: 619
Joined: Sun Jan 03, 2016 4:19 pm
Location: Florida

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Hoptoad »

synthsin75 wrote: Sat Mar 19, 2022 8:32 pmTurns out the only unique layer identifier that survives import is the UUID that identifies a reference layer, but only when not imported as a reference (so it's still referencing it's original layer, instead of being an imported reference of a reference).
Perhaps LostMarble can add some new code to Moho, in the next Moho update, that would give unique layer identifiers to layers that would persist after importing - just to benefit this script and the people who use it.

Personally, I do a lot of importing. I create a new file and import, import, import, import, import.

This is a great script, even without the importing. Thanks.
User avatar
synthsin75
Posts: 9975
Joined: Mon Jan 14, 2008 11:20 pm
Location: Oklahoma
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by synthsin75 »

I can work around the problem. It's just a matter of finding the time to do so.
User avatar
Hoptoad
Posts: 619
Joined: Sun Jan 03, 2016 4:19 pm
Location: Florida

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Hoptoad »

Really?

Take your time. Adding that feature would be gilding the lily, anyhow.
Plus I already concocted a work-around.
User avatar
Greenlaw
Posts: 9269
Joined: Mon Jun 19, 2006 5:45 pm
Location: Los Angeles
Contact:

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Greenlaw »

Hoptoad wrote: Mon Jul 18, 2022 5:35 pm Take your time. Adding that feature would be gilding the lily, anyhow.
Plus I already concocted a work-around.
Oh, I wouldn't say it was gilding the lily...I routinely build projects for import to animation projects, so for me maintaining the layer links is an essential feature; without this ability, LS isn't as useful to me. But also like you, I prefer Wes take his time so it's done right. 😸

I'm curious, what's your workaround? The only one I can think of is to import other assets to the character project that's using Layer Shortcuts but that doesn't work for more than one character using LS.
User avatar
Hoptoad
Posts: 619
Joined: Sun Jan 03, 2016 4:19 pm
Location: Florida

Re: *UPDATED 3/1/19* Layer Shortcuts tool

Post by Hoptoad »

My workaround is a cumbersome, troublesome solution that's also bothersome, loathsome, and annoyingsome.
I highly recommend it.

Simply create a new file called killmenow.moho, and import all your rigged characters into it. Take a deep breath and create the buttons for each and every character. That's the heart of it.
Thereafter, whenever you need a new scene with a couple rigged characters with LS buttons, open killmenow.moho and delete every character that you don't need, leaving the ones you do.

Its brilliance lies in its complexity.
Post Reply