ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Trying to write a script to add a wiggle expression with values via text boxes

COW Forums : Adobe After Effects

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Christian EvansTrying to write a script to add a wiggle expression with values via text boxes
by on Jul 10, 2014 at 12:49:38 am

I'm trying to automate adding a wiggle expression via a script. I want text boxes to pop up to enter the freq and amplitude of the wiggle. So far I have this:

{

//Set Undo Group
app.beginUndoGroup("Wiggle");

wiggleFreq = parseFloat(prompt("Frequency"));
wiggleAmp = parseFloat(prompt("Amplitude"));

var myItems = app.project.selection;
for (var i = 0; i < myItems.length; i++) {
if (myItems[i] instanceof CompItem) {
myItems[i].layer(1).property("Position").expression = "wiggle(effect(wiggleFreq),effect(wiggleAmp))";
}
}


app.endUndoGroup();
}


The text boxes work but I can't figure out how to get the info from the boxes to actually get added to the expression. I get an error every time and it adds the broken wiggle expression. I've tried a few things but I'm out of my depth here.

Also I'd love to be able to add the wiggle to any selected property not just position but I'm not sure how to write that code.

Any ideas?


Return to posts index

Walter SoykaRe: Trying to write a script to add a wiggle expression with values via text boxes
by on Jul 10, 2014 at 11:44:59 am

Your problem with the expression is that the variables wiggleFreq and wiggleAmp only exist within the script; they are not effects that exist in the comp. When writing the expression string, you'll need to use something like the following:

myItems[i].layer(1).property("Position").expression = "wiggle(" + wiggleFreq + "," + wiggleAmp + ");";


As for looping through other properties, check out the Layer selectedProperties attribute on p. 93 of the scripting guide [link].

Walter Soyka
Designer & Mad Scientist at Keen Live [link]
Motion Graphics, Widescreen Events, Presentation Design, and Consulting
@keenlive [twitter]   |   RenderBreak [blog]   |   Profile [LinkedIn]


Return to posts index

Christian EvansRe: Trying to write a script to add a wiggle expression with values via text boxes
by on Jul 10, 2014 at 6:20:04 pm

Awesome, thanks for the help!


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2017 CreativeCOW.net All Rights Reserved
[TOP]