Page 1 of 2

Control all switch layers and bones from parent bone layer

Posted: Wed Aug 08, 2012 5:27 pm
by heyvern
This is a layer script.

This script was used originally in the Fritz character in the Anime Studio content. I just updated this script (it's better than the one I did for the Fritz character).

Instructions and sample ASP file are included in the zip. Embed this script in a parent bone layer. Name bones in parent layer the same as sub switch layers.

hm_switch-layer-bone-control.zip



The Character Wizard content is a good example of how this can be used. Create a CW character with all views. Inside there is a TOP level switch for body angles. Nested Inside each of those layers are the same named switch folders for the mouth, eyes, hands etc etc for each view angle. Put the CW top level switch inside a new bone layer. Create and name bones for all of the nested switches, for example, Man, Mouth, Hand R, Eye R etc etc. You can now control all of those switches for all the nested levels using the top bone layer. No need to key switches by hand in each layer.

Feature overview:
Control ANY and all switch layers ANYWHERE in the document no matter how deeply nested.
Controls switching layers from parent bone layer (matching bone and layer names)
Control bone scales switch layer uniformly (x, y and z)
Control the bones in a switch using same named bones in the parent bone layer.

The "Layer Scaling" is especially fun. Anime Studio bone scaling is only on the Y axis. Bound layers can't be scaled uniformly using a single bone. This script allows for uniform scaling of the controlled switch layer by scaling the control bone. The controlled layer should NOT be bound to the control bone as this will also scale on the Y axis as well.

You can use angle limits on the control bone (bone constraints) to make the switch layer switching interval angle of the bone smaller. It just divides the number of switches into the distance between the min/max of the bone angle limits.
As an extra aid in switching, you could create a vector layer of "dials" bound to the switch control bones (see how I did this in the Fritz file in the Anime Studio content).

Let me know how this works out for you.

-vern

Re: Control all switch layers and bones from parent bone lay

Posted: Wed Aug 08, 2012 7:58 pm
by heyvern
Updated the script so now you can control switch layers with the same name that don't have the same number of switch layers.

For example, one of the character wizard characters was missing a hand layer in the switch. All the the other hand switches had 2 layers. One only had 1 layer. This caused the script to not work obviously it was assumed the duplicate switches would have the same number of layers.

I tweaked the code so now it works with switches that don't have the exact same number of layers. The bone angle will adjust based on the number of layers in the switch automatically. So if you have a bunch of switches with the same name controlled by the same bone, but each one has a different number of layers, the bone angle is divided by EACH layer number.

This can however cause some situations where the layers don't "match". If that is the case you should make sure all the switches have the same number of layers.

Re: Control all switch layers and bones from parent bone lay

Posted: Thu Aug 09, 2012 8:45 am
by DK
That is amazing vern!!!!!
Thanks a bunch for sharing.

Cheers
D.K

Re: Control all switch layers and bones from parent bone lay

Posted: Thu Aug 09, 2012 9:55 am
by Breinmeester
You're posting some valuable scripts, Vern! Glad you're back!! 8)

Re: Control all switch layers and bones from parent bone lay

Posted: Fri Aug 10, 2012 1:39 am
by hothead
Hey Heyvern i am soooo glay to see you back i all log in back. I am a fan of Fritz character so i am going to love this script thank you vern...
:D

Re: Control all switch layers and bones from parent bone lay

Posted: Fri Aug 10, 2012 10:57 am
by Onionskin
Awesome, switch with bone + master controle bone, it works great, thank you very much!
Now I have to find way to embed two embedded scripts on one layer, because I use very often aim_bone_ik_hl script, I should pm to Rudriger.

Re: Control all switch layers and bones from parent bone lay

Posted: Sun Aug 12, 2012 10:16 pm
by funksmaname
Rudiger released a menu script to merge scripts - its around here somewhere... but essentially I think all it did was take all of one script code and put it before or after another script - you could try doing this manually to merge the two? I don't know if they can conflict but maybe worth a try :)

Re: Control all switch layers and bones from parent bone lay

Posted: Mon Aug 13, 2012 2:50 am
by heyvern
My concern merging scripts is possible performance issues. With this script there is the potential for a LOT of activity going on if you have a lot of bones controlling a lot of switches and controlling bones on the switch layer. I have complex files and every once in awhile the script "chokes" for a few seconds when rotating a single bone that controls 10 to 15 switch layers simultaneously.

Another issue regarding combining scripts might be potential variable conflicts. For those who don't do any scripting, we store important stuff in little containers. You muck those up and things go wonky. when we say "variable scope" we don't mean mouth wash.

I will try to track down Rudiger's merging script. It sounds pretty cool. So does the Aim Bone script. I wrote a script like that as well. Love to see how others approach the same idea. My math skills STINK and aiming bones tends to require lots of crazy vector math. I use a lot of bookmarked math sites when writing scripts. :)

--------------

p.s. I wrote up a proposal to SM for improving layer script functionality that would solve this issue and provide the ability to put as many script features as you want into a layer using many function "snippets" in a "wrapper". I thought my concept was pretty simple and cool and might just work. It may not be any time soon, but I have my fingers crossed that it might show up in a future version of Anime Studio. We need a way to have more than one layer script. The main issue is that so many things are repeated a bazillion times over and over and over, like searching bone lists, layer lists, point lists etc. If those could be "built in" functions it could really make life easier.

-vern

Re: Control all switch layers and bones from parent bone lay

Posted: Thu Aug 16, 2012 6:17 pm
by rocky53204
Once again you leave me in wide mouth astonishment! Very cool script... damn shame Smith can't use you as a developer.

Re: Control all switch layers and bones from parent bone lay

Posted: Wed Oct 24, 2012 4:39 am
by Poptoogi
Heyvern,
Funksmaname just pointed me to this thread and all I can say is that's it feels like xmas in October! This script is amazing! I haven't used it yet but I can tell by your video that it does exactly what I need and I'm going to use it all the time! Thanks so much for this!!!!!!!!!

Re: Control all switch layers and bones from parent bone lay

Posted: Sat Nov 03, 2012 8:24 pm
by DrGhaedi
Heyvern,
Guyver93 pointed me to you and this script. Just wanted to thank you for sharing your work with the AS community.

PS
Assuming you are Jim Varney fan? Or is the Hey Vern merely a coincidence?
http://www.youtube.com/watch?v=EimYmcr18Xs :twisted:

Re: Control all switch layers and bones from parent bone lay

Posted: Mon Jul 08, 2013 12:17 am
by otonal
i have a problem with the script as i want to cycle through Image switch layers.

when i set a bone angle at a certain keyframe i have the corresponding Image shown with your script.
when later on in timeline i change the angle, of course the corresponding Image for that is displayed.

-but for the time between those as the bones moves the Image is hold and dont directly cycle according to the moving bones angle as long as i dont keyframe them!
there is no direct link as Long as you dont keyframe the bone position sadly.


lets say i have photos of a clayhead from all angles. i would like to set a startimage/pose with your script and the endpose later in timeline. then the imagerow of the heads rotation step by step contained in the switchlayer should cycle with the altered scriptboneangle.

smart bones dont work with switch layers yet, so i hope there is a mod or a way to do it with your script. so to say to make your script animteable or maybe a second version that does that.

of course the way the script is right now is desireable in many sitauions but i could think of so many situations where a direct boneangle/ swtichlayerswitching link would be wanted as well!

Re: Control all switch layers and bones from parent bone lay

Posted: Mon Jul 08, 2013 2:52 am
by heyvern
otonal wrote:i have a problem with the script as i want to cycle through Image switch layers.

when i set a bone angle at a certain keyframe i have the corresponding Image shown with your script.
when later on in timeline i change the angle, of course the corresponding Image for that is displayed.

-but for the time between those as the bones moves the Image is hold and dont directly cycle according to the moving bones angle as long as i dont keyframe them!
there is no direct link as Long as you dont keyframe the bone position sadly.
Interesting! When I made this script I actually had to avoid that effect otherwise all the layers would cycle through on every frame between keys which is not what most people want with this type of switching. So what you need is an alternative version that DOES cycle through between keys. I can probably add this functionality by checking for something added to the bone name controlling the switch layer.

Will let you know how it goes.

Re: Control all switch layers and bones from parent bone lay

Posted: Mon Jul 08, 2013 10:16 am
by otonal
8)

Re: Control all switch layers and bones from parent bone lay

Posted: Thu Jul 11, 2013 4:11 pm
by RichardU
This is way cool, but there is one final thing I can't seem to control from the highest bone layer. I have a sub bone layer for Head, with Smartbones to control vector layers inside. I'm trying to figure out how to have those smartbones on the highest bone layer. I've tried converting the Head bone layer to a group layer, but I can't get the highest bone layer to do point animation on vector layers within a sub group/bone layer. What's the best workaround?