Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Extendscript – Dropdownlist on change and retrieving Compositions

  • Extendscript – Dropdownlist on change and retrieving Compositions

    Posted by Benoit Kergosien on March 29, 2015 at 7:03 pm

    Hi folks!

    I’m trying to create a script based on two dropdownlists:

    the first can access to all the comps of the project
    the second access to specific layers of the comp selected previously with the first dropdownlist.

    I stored the comp’s names in an array and apply them in my first dropdown list.
    But I can’t set up a way to specify the comp selected in the dropdownlist to access to its layers.

    Do I have to used names, index, item id and how to do this?

    So far my code is the following (including errors):

    ==========

    // detect the language
    var utils = this;
    this.loc = function (str)
    {
    var lang = parseFloat(app.version) < 9 ? $.locale : app.isoLanguage;
    return lang.toLowerCase().match(“fr”) ? str.fr : str.en;
    };

    // store Compositions
    function grabAllComps(){
    var proj, itemTotal, curItem, itemAry
    itemAry = new Array();
    proj = app.project;
    itemTotal = proj.numItems;
    for(var i=1; i<=itemTotal; i++){
    curItem=proj.item(i);
    if(curItem instanceof CompItem){
    itemAry[itemAry.length] = curItem.name;
    }
    }
    return itemAry
    }
    // store specific Layers of the Compositon selected in the dropdownlist

    var ddlCompSelected = dropComp.onChange();
    var layers = ddlCompSelected.layers;
    var matchingLayers = new Array();
    var layer;
    function grabSpecificLayers(){
    for (var i = 1; i <= layers.length; i++)
    {
    layer = layers[i];

    if (!(layer instanceof ShapeLayer) && !(layer instanceof CameraLayer) && !(layer instanceof LightLayer) && !(layer.adjustmentLayer) && !(layer instanceof TextLayer) && !(layer.nullLayer))
    {
    matchingLayers[matchingLayers.length] = layer.index +” : ” + layer.name;
    }
    }
    return matchingLayers
    }

    // Steps Text
    this.firstStep = {en:”Select a comp”,fr:”Sélectionner une composition”};
    this.secondStep = {en:”Select a layer”,fr:”Sélectionner un calque”};

    // BUILD UI
    var myWin = new Window(“palette”,””,undefined);
    myWin.orientation = “row”;
    var panelOne = myWin.add(“panel”, undefined,”dropdownlist test”);
    panelOne.add(“statictext”,undefined,utils.loc(this.firstStep));
    var dropComp = panelOne.add(“dropdownlist”,[0,0,200,20],grabAllComps());
    //dropComp.selection=1;
    dropComp.onChange = function () {
    this.selection.text;
    }
    panelOne.add(“statictext”,undefined,utils.loc(this.secondStep));
    var dropLayer = panelOne.add(“dropdownlist”,[0,0,200,20],grabSpecificLayers());
    dropLayer.selection=1;

    myWin.center();
    myWin.show();

    ==========

    Thanks for your help.

    Benoit Kergosien replied 11 years, 1 month ago 1 Member · 0 Replies
  • 0 Replies

Sorry, there were no replies found.

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