A little syntax help + a general help

What type of scripts do you need?

Moderator: byronnash

Post Reply
The_Dove
Posts: 1
Joined: January 14th, 2009, 2:33 am

Hello, I would like to add a expression to a selected effect to a script!
For e.g., i create a new solid, add a fast blur on it, and then run my script, and my expression would be on the effect.
"var myFx = app.project.activeItem.selectedLayers.Effects;" this sentence isn't right, because i'have to refer a effect... in fact i would like to get the keyword for "selectedEffect" if there is one.

Now, in a more global way, i would like to know if you guys know some great stuff to learn seriously more about scripting and expression.
I've searched a lot on the web, and i didn't found any serious help (you know like the adobe help) even in the book way, i've only found ONE serious looking book about expression and scripting...

I'd like to improve myself and stop wasting hours trying to write huge script only because i don't know all the shortcuts...

Thanks in advance, ladies.
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

The new Studio Techniques book has a whole chapter on expressions written by none-else than Dan Ebberts and a chapter on Scripting written by the head of scripting at Adobe Jeff Almasol:

http://www.amazon.com/gp/product/032159 ... 0321592018

Now to your question, to add an expression you just add .expression and write your expression like this:

var myLayer = app.project.activeItem.selectedLayers[0]; //this refers to the top selected layer in the current comp

myLayer.position.expression = "wiggle(15,10);" //this adds a wiggle expression to the position channel


There isnt a way to get the selected effect unfortunately, you need to call it either by name or index:

var myEffect = myLayer.property("Effects").property("Box Blur") //refers to the first effect named Box Blur

var myEffect = myLayer.property("Effects").property(2) //refers to the second effect

So to add an expression the radius of the box blur you would do it like this:

myEffect.property("Blur Radius").expression = "wiggle(15,10);";


Hope this helps,

Lloyd
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: CA
Contact:

oh, i'm definitely not the head of scripting at adobe, but i do the best i can to know about scripting in after effects. :-)

:jeff
User avatar
lloydalvarez
Enhancement master
Posts: 460
Joined: June 17th, 2004, 9:27 am
Location: New York City, NY
Contact:

Well you are number 1 in my book!
:D
-Lloyd
Post Reply