Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Use Comp Name to drive position expression

  • Use Comp Name to drive position expression

    Posted by Criis Daw on October 25, 2012 at 12:28 pm

    Hi Everyone..

    I have tried following some previous threads but cant get it to work so i give up.. I’ll ask

    I am trying to get the comp name , specifically the last number to determine to position of a layer in the comp.

    ie

    Screen01_frame01_flap_01

    etc I would like to be able to link the y postion to the number of the flap.

    Anyone ??

    Criis Daw replied 13 years, 6 months ago 2 Members · 6 Replies
  • 6 Replies
  • Dan Ebberts

    October 25, 2012 at 3:25 pm

    Something like this should work:

    nameSplit = thisComp.name.split(“_”);
    compNum = parseInt(nameSplit[nameSplit.length-1],10);
    value – [0,compNum*100]

    Dan

  • Criis Daw

    October 26, 2012 at 9:58 am

    thanks for that..

    will try it now..

    back in a minute when i mess it up ..

    cheers

  • Criis Daw

    October 29, 2012 at 4:06 pm

    Hi

    dont supose you could help me a little more could you .

    I copy the expression into the postion property and I understand how the y postion is calculated.

    for example comp number 17 in a comp 52 pixels high ends up with a Y value of -2530.

    why is that ..?

    If I understood how this number is attained I could make it so I get the number I want which is, (comp number-1)*52 . the height od the comp

    thanks

  • Criis Daw

    October 29, 2012 at 4:19 pm

    ahhh

    its ok .

    I figured out why it was not what I expected. the expression is applied to the value of the layer .. which I had already set…I works fine if I reset it to zero.

    Still If you have 5 minutes to explain a little i would be very thankful.

    cheers

    Chris

  • Dan Ebberts

    October 29, 2012 at 10:48 pm

    The part that converts the comp name to a number? It’s all core JavaScript. The split() function to split the comp name into an array of strings, using “_” as the delimiter. The comp number will be in the last element of the array, which you access with nameSplit[nameSplit.length-1]. Then you use parseInt() to convert the string version of the number to a decimal number.

    Dan

  • Criis Daw

    October 30, 2012 at 5:26 pm

    thanks..

    i understand i a little better.

    thanks for your help with this

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