Copy link to clipboard
Copied
What I'm trying to accomplish is to have a specific number in an expression change based off a number in the composition name.
I have a character rig composition which needs to be used in several seperate compositions (Scenes). I have attached the rig controls to expression controls in a seperate Scene. However, in order to animate the character in each seperate Scene, I need to dedicate a character rig composition for each scene. For Example, Character Rig_Scene 1 is used in Scene 1, Character Rig_Scene 2 is used in Scene 2, etc.
Each time I duplicate my Character Rig_Scene #, I'd like the number to automatically change in the comp("Scene #") part of the expression. So comp("Scene 4") will pull the number from "Character Rig_Scene 4" composition.
Can this be accomplished? If so, what's a good approach?
Thanks for your help.
Please see photo for more context.
I think something like this should work:
comp("Scene " + thisComp.name.split(" ").pop()).layer("Taylor Animation Control").effect("L Arm")("Angle")
Copy link to clipboard
Copied
I think something like this should work:
comp("Scene " + thisComp.name.split(" ").pop()).layer("Taylor Animation Control").effect("L Arm")("Angle")
Copy link to clipboard
Copied
Golly! That worked, thank you very much.
So how is this expression working now? Like how does it know to read the Scene #?
Copy link to clipboard
Copied
It takes the name of the comp with the expression, splits that into an array of chunks wherever there's a space in the name, and then takes the last chunk (which is "4" in your example) and appends that to "Scene ".
Copy link to clipboard
Copied
Okay, I think I'm understanding. So the .pop() is how you are telling it to only see the last part – so the "4"?
Copy link to clipboard
Copied
Yes.
thisComp.name.split(" ")
Gives you this array:
["Taylor", "2.0_Scene", "4"]
and the .pop() gives you the last element of the array.
Copy link to clipboard
Copied
Incredible. Expressions rule!
Thank you much for your help and explanation on this.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now