Copy link to clipboard
Copied
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.
Something like this would give you the number:
parseInt(thisComp.name.split("_")[1],10);
Dan
Copy link to clipboard
Copied
Something like this would give you the number:
parseInt(thisComp.name.split("_")[1],10);
Dan
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
This was very useful, but it sent me down an internet hole trying to figure out what the ",10" was doing in the parseInt function.
I discovered that it designates the numeric system as base-10 (i.e. decimal). Apparently, if you leave that out of the expression, base-10 is automatically assumed. Why did you add it here?
Copy link to clipboard
Copied
Force of habit, mostly, but try parseInt(016) and see what you get. If you have an integer that starts with "0", for some strange reason, JavaScript will first try to interpret it as octal. So I include the ",10" just to be safe.