Script for switching multiple switches simultaneously
Moderators: Víctor Paredes, Belgarath, slowtiger
Script for switching multiple switches simultaneously
I have a situation with switches inside switches and a LO them
I would like to be able to switch a lot of them ( within a group) at the same time ( they have consistent names), rather than trawling through all the layers to switch them manually which takes 'stoopid' time.
So my obvious next question is... does anyone have a script for that?
I would like to be able to switch a lot of them ( within a group) at the same time ( they have consistent names), rather than trawling through all the layers to switch them manually which takes 'stoopid' time.
So my obvious next question is... does anyone have a script for that?
- Víctor Paredes
- Site Admin
- Posts: 5658
- Joined: Wed Jan 26, 2005 12:18 am
- Location: Barcelona/Chile
- Contact:
Re: Script for switching multiple switches simultaneously
I have the idea I saw a script for that in the past (probably a very old one), but what about using References instead?
Moho Product Manager
www.mohoanimation.com
Rigged animation supervisor in My father's dragon - Lead Moho artist in Wolfwalkers - Cartoon Saloon - My personal Youtube Channel
Re: Script for switching multiple switches simultaneously
I can't see that working in this 'instance' ... sorry for the pun.Víctor Paredes wrote: what about using References instead?
Seriously though that would get too messy for my liking and I'm way too far down the track for that.
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Script for switching multiple switches simultaneously
this one?Víctor Paredes wrote:I have the idea I saw a script for that in the past (probably a very old one),...
http://lostmarble.com/forum/viewtopic.php?f=12&t=27094
Re: Script for switching multiple switches simultaneously
Hey thanks!
OH this works brilliantly... even in my switch within a switch... took a little braining ... but yeah ... thanks guys!
I'd love to see this as a layer checkbox built in...
OH this works brilliantly... even in my switch within a switch... took a little braining ... but yeah ... thanks guys!
I'd love to see this as a layer checkbox built in...
Re: Script for switching multiple switches simultaneously
Hey, I wonder if the same type of script could 'trick' interpolation in nested layers ?
Re: Script for switching multiple switches simultaneously
I also wonder if it could be adapted for visibility , when switch groups can't be used due to the 'exclude strokes' masking limitation.
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Script for switching multiple switches simultaneously
yes - it's neat -- doesn't (yet) deal with cycle keys tho.chucky wrote:Hey thanks!
OH this works brilliantly... even in my switch within a switch... took a little braining ... but yeah ... thanks guys!
I'd love to see this as a layer checkbox built in...
and +1 to making this a standard feature.
it could probably be extended do that (with all the same limitations as interp now - e.g. same number of points in essentially the same sequence(s) in path(s) - straight-line displacement... ) -- something along the lines of getting the point position in the active child; get the point position in the "to be active" child; and number-crunch the difference -- similar in concept to the "follow target bone in a different layer" (http://lostmarble.com/forum/viewtopic.php?f=13&t=31302)chucky wrote:Hey, I wonder if the same type of script could 'trick' interpolation in nested layers ?
well, IMO yes - any attribute in a "master" can be accessed and applied to a "slave" -- this script looks for keys frames in SwitchValues - a variation could easily look for keys in layer visibilitychucky wrote:I also wonder if it could be adapted for visibility , when switch groups can't be used due to the 'exclude strokes' masking limitation.
Re: Script for switching multiple switches simultaneously
Yes that idea of a visibility variant , would really help me.
I can see this script is super short..wow!
If only I knew the first thing about this stuff. Guess it would be a matter of maybe changing a few of the words?
And instead of
if (Layer:LayerType() == 5) then --CHECK FOR SWITCHLAYER
it might look for the layer visibility value?
See I'm already out of my depth, but to my inexperienced eye , is it that only three or four lines need to change?
I can see this script is super short..wow!
If only I knew the first thing about this stuff. Guess it would be a matter of maybe changing a few of the words?
And instead of
if (Layer:LayerType() == 5) then --CHECK FOR SWITCHLAYER
it might look for the layer visibility value?
See I'm already out of my depth, but to my inexperienced eye , is it that only three or four lines need to change?
Code: Select all
function LayerScript(moho)
local ControlLayer = moho.layer
local Parent = moho.layer
function SlaveCheck(Parent)
local group = moho:LayerAsGroup(Parent)
for i=0,group:CountLayers()-1 do
local Layer = group:Layer(i)
if (Layer:LayerType() == 5) then --CHECK FOR SWITCHLAYER
Layer = moho:LayerAsSwitch(Layer)
local name = ControlLayer:Name() .. ".SLAVE"
if name == Layer:Name() then
local master = ControlLayer:SwitchValues()
if master:HasKey(moho.frame) then
Layer:SwitchValues():SetValue(moho.frame,master:GetValue(moho.frame))
elseif Layer:SwitchValues():HasKey(moho.frame) then
Layer:SwitchValues():DeleteKey(moho.frame)
end
end
end
if Layer:IsGroupType() then
SlaveCheck(Layer)
end
end
end
while go == nil do --FIRST LOOK FOR MASTER CHARACTER LAYER
Parent = Parent:Parent()
if Parent == nil then
break
else
local CheckMaster = string.match(Parent:Name(),".MASTER")
if CheckMaster ~= nil and Parent:IsGroupType() then
SlaveCheck(Parent)
break
end
end
end
end
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Script for switching multiple switches simultaneously
I've had a longer ponder and I think there are many ways to pluck the pelt from that proverbial pussy ... and the exact scripting solution depends on how you want to organise / use your file.chucky wrote:Yes that idea of a visibility variant , would really help me.
one option:
Group Layer
> child layers
layer script to look for a new "visibility on" key in a child layer and set all the others to "visibility off" (i.e. the "visibility variant")
another option:
Group Layer
> child layers
(tool) script (based on the standard LM_SwitchLayer tool) to set visibility on for just one chid layer (i.e. to simulate a switch)
yet another option:
Group layer
>real child layers
Switch layer
> dummy child layers each named as per the Group
(layer) script the Group layer to toggle visibility of its child layers to match the selected switch layer
(as a sub option one set of child layers might hold fill vectors and the other holds the strokes - and use the appropriate one as a mask -- but if you're going in that direction you might just as well have two switch layers and use the current script solution)
(optional tool script to auto-generate the dummy child layers)
====
IMO a tool script based on the standard LM_SwitchLayer tool is probably easiest from a usability point of view
thoughts??
Re: Script for switching multiple switches simultaneously
Well the pussy seams to be half skinned already, it seems.
THis slave visibility would be the most expedient for me.
I have a working solution but it involves many, many, many layers and is boring to work with.
Any other solution could be even worse.
It all really down to the fact that there is no option to exclude strokes from masks inside a group.
I'm way too far into the project to rebuild too much now. I've posted a screener.
You can see the layer script slaving the teeth layers and working nicely.
So I'm using a top level switch with references of the whole kit and caboodle, which triples the layer count and I had to toggle off each lip option for all three reference groups. It feels like I'm wearing a hat with a hat and a hat on top.
Slaving the visibility would be much cleaner .
Oh yes, I'm obviously just hiding the layer rather than toggling visibility, it's clearer for now.
THis slave visibility would be the most expedient for me.
I have a working solution but it involves many, many, many layers and is boring to work with.
Any other solution could be even worse.
It all really down to the fact that there is no option to exclude strokes from masks inside a group.
I'm way too far into the project to rebuild too much now. I've posted a screener.
You can see the layer script slaving the teeth layers and working nicely.
So I'm using a top level switch with references of the whole kit and caboodle, which triples the layer count and I had to toggle off each lip option for all three reference groups. It feels like I'm wearing a hat with a hat and a hat on top.
Slaving the visibility would be much cleaner .
Oh yes, I'm obviously just hiding the layer rather than toggling visibility, it's clearer for now.
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Script for switching multiple switches simultaneously
so to check that I understand this - you have multiple instances of (say) Top Heavy Lips (vector) and when the master one gets its visibility changed then all the others should too? (Not too tricky)
or is it if the master Top Heavy Lips (vector) gets its visibility changed then as well as all slave Top Heavy Lips changing, all Thin Lips and Thick Lips (and ..) need to have their visibility changed too? (trickier)
and is this just a frame zero set-up (or is it timeline animated)?
and are the multiple instances of the character set-up top-level group in a file?
==
((a main difference between the visibility variant and the switch base version is that a master for visibility could be any type of layer (vector, group, ...) so the actual way of finding a master and its slaves is not quite the same as the way the original code looks for switch layers))
or is it if the master Top Heavy Lips (vector) gets its visibility changed then as well as all slave Top Heavy Lips changing, all Thin Lips and Thick Lips (and ..) need to have their visibility changed too? (trickier)
and is this just a frame zero set-up (or is it timeline animated)?
and are the multiple instances of the character set-up top-level group in a file?
==
((a main difference between the visibility variant and the switch base version is that a master for visibility could be any type of layer (vector, group, ...) so the actual way of finding a master and its slaves is not quite the same as the way the original code looks for switch layers))
Re: Script for switching multiple switches simultaneously
So, instead of switching between those large 'red' groups, I just have the one red group that contains all the lips.
So when I change the master ('pink' top heavy lips) to on, then all the pink top heavy lips inside the 'coral' phoneme/expression sub groups change too.
I won't need the top level 'red' top heavy groups any more and I will delete those, there will just be the coral coloured groups under the selected mouth group.
Is that the simper version?
It's all pretty hard to explain/follow with words eh?
Oh it doesn't need to animate and it would only be in that one red mouth folder
So when I change the master ('pink' top heavy lips) to on, then all the pink top heavy lips inside the 'coral' phoneme/expression sub groups change too.
I won't need the top level 'red' top heavy groups any more and I will delete those, there will just be the coral coloured groups under the selected mouth group.
Is that the simper version?
It's all pretty hard to explain/follow with words eh?
Oh it doesn't need to animate and it would only be in that one red mouth folder
- hayasidist
- Posts: 3511
- Joined: Wed Feb 16, 2011 8:12 pm
- Location: Kent, England
Re: Script for switching multiple switches simultaneously
is this right?
file contains one switch for mouth types
each mouth type child has a switch for phoneme
each phoneme child has vectors for all mouth types
whichever child of "mouth types" is active make the corresponding vectors in all phonemes active and make all the rest not visible
e.g.
mouth type active child is "fat"
for all phonemes in "fat"
> make visible all vectors for "fat"
> make invisible all vectors for other mouth types
file contains one switch for mouth types
each mouth type child has a switch for phoneme
each phoneme child has vectors for all mouth types
whichever child of "mouth types" is active make the corresponding vectors in all phonemes active and make all the rest not visible
e.g.
mouth type active child is "fat"
for all phonemes in "fat"
> make visible all vectors for "fat"
> make invisible all vectors for other mouth types
Re: Script for switching multiple switches simultaneously
Ahh that 's a good way to explain.
I would like to have this....
File contains switch for phonemes called mouth.
Each phonemes has lips that mask the other layers.
Each phonemes has lip types ( three so far)
On of the phonemes is the master.
Change the visibility of lips in the master phoneme and the lips in all the phonemes correspond.
This is different , to what I have shown, which is the current setup with mouth types.
I want to delete the mouth types just , even though it is working , just because it is unwieldy and inelegant.
I'll the have one mouth only.
I would like to have this....
File contains switch for phonemes called mouth.
Each phonemes has lips that mask the other layers.
Each phonemes has lip types ( three so far)
On of the phonemes is the master.
Change the visibility of lips in the master phoneme and the lips in all the phonemes correspond.
This is different , to what I have shown, which is the current setup with mouth types.
I want to delete the mouth types just , even though it is working , just because it is unwieldy and inelegant.
I'll the have one mouth only.