Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions AE scripting – passing UI value field to a solid size

  • AE scripting – passing UI value field to a solid size

    Posted by Nicolas Elsig on May 7, 2010 at 12:21 pm

    Hello

    I’m trying to make simple script to learn AE scripting language and I would like to know if someone could help me … I’m just trying to pass a value from a text field in my UI Panel to a solid after pushing a create button… what seems to be simple … is just a torture for me

    I created the button and assigned the script to create the solid … this is ok (it’s the beginner tutorial on another website) then I created a text field and I want to be able to put a value before pushing my create solid button… to not complicate with two text fields, the solid generated I would be a square 😛

    Is there a structure base, a template or something to help create this … I tried to examine a lot and a lot of different scripts and I didn’t ended in a solution

    I will continue to try.. but if somebody have a simple and elegant solution… thanks a lot

    Why is there so less tutorials and documentation for AE scripting ? Do we have to be a developper to script in AE ?

    thanks a lot for your help

    var sizeInit = Number(75);//setup size variable
    ///////
    win.tailleVal = win.add('edittext', [100,120,150,140], sizeInit);
    win.tailleVal.onChange = function () {onSizeChange();};
    ///////
    function onSizeChange(){//when a user changes the size
    var sizeval = Number(tailleVal.text);//take the size value
    writeLn("solid size changed to: " + sizeval);
    return sizeval;
    }

    ///////
    newLayer = currentComp.layers.addSolid([0,1.0,0], newName, sizeVal, sizeVal, 1);
    newLayer.name = newName;

    Nicolas Elsig replied 16 years, 2 months ago 2 Members · 2 Replies
  • 2 Replies
  • Ram Manohar

    May 8, 2010 at 10:10 am

    Hi.. Nicolas
    Try this one., Its working..Is this you want..??

    still any problem let me know..
    https://myaescripts.blogspot.com/

    //This script is to create a solid (square shape) with specified size..,
    //The size of the solid can be specified by the user in TextBox...
    {
    var myPanel;
    //function for building UI
    function Create_Solid(thisObj)
    {
    myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Create Solid", [100, 100, 300, 300]);
    myPanel.txtbox = myPanel.add("edittext", [10, 5, 90, 25]);
    myPanel.butCreate = myPanel.add("button", [10, 40, 90, 60], "Create Solid");

    myPanel.butCreate.onClick=Createlayer;
    return myPanel;
    }

    function Createlayer()
    {
    app.beginUndoGroup("Create Solid");
    if ((app.project.activeItem == null) || ((app.project.activeItem != null) && !(app.project.activeItem instanceof CompItem)))
    {
    alert("Please establish a comp as the active item and run the script again");
    }
    else
    {
    var xy=parseInt(myPanel.txtbox.text);
    var comp = app.project.activeItem;
    var solidName = "New Solid";
    var solidW = xy;
    var solidH = xy;
    var solidPixelAspectRatio = comp.pixelAspect;
    var solidDuration = comp.duration;
    var newsolid = comp.layers.addSolid([0, 1, 0], solidName, solidW, solidH, solidPixelAspectRatio, solidDuration);
    }
    app.endUndoGroup();
    }

    Create_Solid(this);

    }

    manohar

  • Nicolas Elsig

    May 8, 2010 at 4:51 pm

    thank you so much … I will analyze this script and try to understand exactly what each line do.

    Thank you for your help and the time you took to write this script

    All the best
    Nicolas

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