Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Trying to write a script to add a wiggle expression with values via text boxes

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

    Posted by Christian Evans on July 10, 2014 at 12:49 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?

    Christian Evans replied 12 years ago 2 Members · 2 Replies
  • 2 Replies
  • Walter Soyka

    July 10, 2014 at 11:44 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   |   RenderBreak [blog]   |   Profile [LinkedIn]

  • Christian Evans

    July 10, 2014 at 6:20 pm

    Awesome, thanks for the help!

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy