Creative COW SIGN IN :: SPONSORS :: ABOUT US :: CONTACT US
ADOBE AFTER EFFECTS: HomeForumBasicsExpressionsTutorialsPodcastsMotion GraphicsTrainingCinema 4DFAQ

Can an expression acknowledge the Comp's name?

Cow Forums : Adobe After Effects Expressions

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>
Can an expression acknowledge the Comp's name?
by Bert Brown on Nov 13, 2008 at 5:22:58 pm

I have to create many variations of a comp. There is a specific labeling system I have to use and I'm wondering if I can set up a if-then situation to adjust parameters based on what I name the comp.

so for example i have a comp name:

PRIMEHD_P2_L2_TSS

and I want the expression to look for the number after that "L" and adjust a slider number (BAR LENGTH SLIDER) to match that digit. in this case "2"

possible? i ask because i know very little about how to format a label to be read, especially pin-pointing a specific position in that label.

thanks

----------------------------------


peep my over-the-interweb band, red abbott.
"we electro-rock over long distances..."

Respond to this post   •   Return to posts index


Re: Can an expression acknowledge the Comp's name?
by Darby Edelen on Nov 13, 2008 at 5:46:25 pm

[Bert Brown] "so for example i have a comp name:

PRIMEHD_P2_L2_TSS

and I want the expression to look for the number after that "L" and adjust a slider number (BAR LENGTH SLIDER) to match that digit. in this case "2""


I think this should get you most of the way there:


n = thisComp.name;
a = n.split("_");


a will be an array with the following values:


a[0] = PRIMEHD
a[1] = P2
a[2] = L2
a[3] = TSS


So to get the digit in a[2] you could use:

dig = a[2].charAt(1) * 1; //multiply by one to convert character to an integer

I haven't tested this but I believe it should work.

Darby Edelen

Respond to this post   •   Return to posts index

Re: Can an expression acknowledge the Comp's name?
by Bert Brown on Nov 13, 2008 at 6:12:26 pm

radical. works great. thanks so much

this is also really helpful for just understanding the way expressions can use text. i had never utilized split or charAt

if i wanted an expression to look at a character, like the "L" how would i do that? just not multiply by 1?



----------------------------------


peep my over-the-interweb band, red abbott.
"we electro-rock over long distances..."

Respond to this post   •   Return to posts index



Re: Can an expression acknowledge the Comp's name?
by Dan Ebberts on Nov 13, 2008 at 6:16:37 pm

Another way:

n = thisComp.name;
parseInt(n[n.indexOf("_L") + 2],10)


Dan



Respond to this post   •   Return to posts index

Re: Can an expression acknowledge the Comp's name?
by Lloyd Alvarez on Nov 14, 2008 at 5:39:44 am

c=thisComp.name

c.charAt(c.lastIndexOf("_")-1)


Since we're doing remixes, here's my take on it ;-)

-Lloyd

http://aescripts.com

Respond to this post   •   Return to posts index

Re: Can an expression acknowledge the Comp's name?
by Lloyd Alvarez on Nov 14, 2008 at 5:49:07 am

forgot that it needed to be used as a number:


c=thisComp.name
parseInt(c.charAt(c.lastIndexOf("_")-1),10)



BTW, just recently learned about the various flavors of parseInt so if you are following along at home, make sure to add the ,10 whenever you use parseInt to make sure you pull base 10 numbers which I imagine is what you'll want 99% of the time..


-Lloyd

http://aescripts.com

Respond to this post   •   Return to posts index


Re: Can an expression acknowledge the Comp's name?
by Darby Edelen on Nov 16, 2008 at 11:53:25 pm

In a case where there is not a need to convert from an arbitrary base to decimal, wouldn't multiplying or dividing by 1 be easier to implement? And also decrease the chances of accidentally misinterpreting the string as octal?

Darby Edelen

Respond to this post   •   Return to posts index

Re: Can an expression acknowledge the Comp's name?
by Dan Ebberts on Nov 17, 2008 at 7:14:27 pm

Good point. In a case like this it would make sense to take advantage of JavaScript's implict type conversions. I think I'd use 0 + though. Just like you can convert a number to a string like this:

n = 1234.567;
"" + n;

You could go the other way like this:

str = "1234.567";
0 + str;


Dan



Respond to this post   •   Return to posts index

Re: Can an expression acknowledge the Comp's name?
by Lloyd Alvarez on Nov 21, 2008 at 7:47:53 pm

I love the fact that I am always learning new things from you guys. :-)

-Lloyd

http://aescripts.com

Respond to this post   •   Return to posts index

<< PREVIOUS THREAD   •   VIEW ALL THREADS   •   PRINT   •   NEXT THREAD >>


FORUMSTUTORIALSMAGAZINETRAININGVIDEOS - REELSPODCASTSEVENTSSERVICESNEWSLETTERNEWSBLOGS

© CreativeCOW.net All rights are reserved.

[Top]