Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Pick-whip nested comp name expression

  • Pick-whip nested comp name expression

    Posted by Joao Monteiro on April 12, 2016 at 9:30 am

    Hi there,

    Hope you are well.
    I’ve rigged a very simple character inside a precomp (circle character), that bounces, blink eyes etc. whith control sliders, check boxes etc.

    But now when I’m working on my main (top level comp), I don’t want to go inside my characters precomps etc to animate them. So, basically I’ve copied all the effects (expressions) to my nested comp and then linked all the expressions from the precomp into the nested comp.

    It works fine, but now I want to be able to duplicate my characters and control them individually.

    So my question is: Is there anyway of getting the nested comp layer name without having to manually pick whipping it within all my precomps?

    Here is what I’ve got just in case you didn’t understand my rambling doubts.

    Top Level comp is *Main
    Character Comp is Character Preset
    Character precomp is where all the controls are originally.
    Expressions is a null inside Character precomp where all the control sliders etc are. So these are the ones to be connected to the copied effects now pasted on my Character comp directly.

    Example:

    comp(“*Main”).layer(“_Character-Preset-1”).effect(“Mouth Control”)(“Checkbox”)

    My Idea:

    comp(“*Main”).layer(nestedLayer??).effect(“Mouth Control”)(“Checkbox”)

    Thanks in advance.
    All the best
    Joao Monteiro

    https://www.joaomonteiro.tv

    Example:

    comp("*Main").layer("_Character-Preset-1").effect("Mouth Control")("Checkbox")

    My Idea:

    comp("*Main").layer.nestedLayer.effect("Mouth Control")("Checkbox")

    Miguel De mendoza replied 10 years, 1 month ago 2 Members · 5 Replies
  • 5 Replies
  • Miguel De mendoza

    April 12, 2016 at 11:07 am

    I think the best way is using split() function. Let’s say you have a character comp named”Character_1″, with all that expressions and controls inside it. Put your character on a scene comp and then you can write this code above all your linked properties :

    nameSplit = thisComp.name.split("_");
    characterNum = nameSplit[nameSplitLength -1];
    selfComp = "Character_" + characterNum;

    Then, you can use the selfComp variable to link the properties to the self comp:

    masterPosition = comp(selfComp).layer("myLayer").transform.position;

    At this point, you can setup one character and then duplicate it on the project, ensuring that the name changes from “Character_1” to “Character_2”, “Character_3” etc. Now you can duplicate your character layer in the main comp and alt+drag the correspondig character comp to his layer.

  • Joao Monteiro

    April 14, 2016 at 2:19 pm

    Hi Miguel,

    Thanks a lot for looking at it.
    It seems so well explained which is making me feel dumber! As I still didn’t get it to work properly.
    Here is a scene file of a test scene.

    9976_expressionstest.aep.zip

    At the moment I’ve linked the opacity of a solid to slider control inside a null (“EXPRESSIONS”). These are inside a comp called (“Character_1”). Now on the comp (“Character_1”) on the main level I’ve copied the Slider control from the precomp and linked the slider inside the precomp to the slider on the comp.

    So I control it from the main comp. So far so good. But at the moment using your help I’ve
    typed:

    nameSplit = thisComp.name.split(“_”);
    characterNum = nameSplit[nameSplitLength -1];
    selfComp = “Character_” + characterNum;
    comp(“*Main”).layer(selfComp).effect(“Opacity Slider”)(“Slider”);

    on my Opacity Slider on the precomp, to link it to the nested precomp but not being able to make it work.

    Sorry for all this rambling, if you check the AE file you will get it straightaway.

    9976_expressionstest.aep.zip

  • Miguel De mendoza

    April 14, 2016 at 2:59 pm

    I see, you have to do the inverse of what I told you XD. There are little erros on your code too, so I think is better to see how it works in the project:

    9977_9976expressionstestedited.aep.zip

    As you can see, tha sliders on the main comp, work independent with the same expression inside of the comps.

  • Joao Monteiro

    April 14, 2016 at 3:14 pm

    You Rock!! Thanks so much.
    Just noticed I had a expression mistake “nameSplitLength -1” instead of “nameSplit.length -1”
    This will help me a lot, thanks again.

    Just to recap and try to learn:

    split(“_”) – breaks a text source in 2 arrays when it sees this character “_”.

    so, (Character_) is array [0] and (CharacterNumb) is [1].

    (nameSplit.length -1 ) means deleting the hole half that comes after (“_”) or just one number with one digit?

    Thanks once again.
    Joao

  • Miguel De mendoza

    April 14, 2016 at 3:33 pm

    split() function splits a string by the character passed as an argument, and it returns one array of x length, in that case length of 2. Accesing to the array nameSplit[nameSplit.length -1 ] is only to ensure that you are accesing the last element of the array, so you can write more complex names like “Yellow_fish_character_1” and still getting the correct number of the name.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy