Skip to main content
Participant
December 16, 2016
Answered

Use part of the name of a comp in expression

  • December 16, 2016
  • 1 reply
  • 2383 views

Hello there,

I want to use part of the name of a comp to automate the actualization of expressions when duplicate this comps and the precomps in them. I labeled them as name_twodigitnumber, so I was wondering if there is some way to use Comp.name or a similar expression to get just the ending two digits number of the name of the comp as output, so they can actualize automatically when I make some duplicates. Hope the explanation is good enough.

Thanks in advance.

Diego.

This topic has been closed for replies.
Correct answer Dan Ebberts

Something like this would give you the number:

parseInt(thisComp.name.split("_")[1],10);

Dan

1 reply

Dan Ebberts
Community Expert
Dan EbbertsCommunity ExpertCorrect answer
Community Expert
December 16, 2016

Something like this would give you the number:

parseInt(thisComp.name.split("_")[1],10);

Dan

DhominusAuthor
Participant
December 16, 2016

Thank you Dan. That seem to do the trick. Nonetheless doing several tests I came up with something like this below, as long as I still do not get how parseInt work exactly, and I prefer to go slow or workaround in order to understand what im using.

I want to get an "N" output referring another composition called "Holder_XX", where XX is a number with two digits, so I used this:

N=comp(("Holder_")+thisComp.name.split("_")[1]);

In order to increase automatically the "XX" (two digits number) by the name of the composition where im writing the script (name_yy).

Best regards, Diego.