Forum Replies Created

Page 3 of 3
  • James Ronan

    April 25, 2018 at 10:10 am in reply to: Animate Scale Y Axis to Audio Amplitude

    Try changing the last line [s,s] to this:

    [value[0],s]

  • James Ronan

    April 19, 2018 at 12:19 pm in reply to: How to replace one line of code in multiple layers?!

    This sounded quite like an interesting task so thought I’d give it ago. Bit rough, and haven’t done a lot of testing but it should replace every instance of that word, project wide.

    Make sure the value for the oldWord variable has ‘/’ and ‘/g’ before and after it so that it doesn’t only change the first instance of the word per expression.

    var oldWord = /old/g;
    var newWord = "new";

    app.beginUndoGroup("Expression Swap");

    for (var a = 1; a <= app.project.numItems; a++) {
    if (app.project.item(a) instanceof CompItem) {

    for (var b = 1; b <= app.project.item(a).layers.length; b++) {
    scanPropGroupProperties(app.project.item(a).layer(b));

    } // end of layer loop
    } // end of check if comp item
    } // end of comp loop

    app.endUndoGroup();

    function scanPropGroupProperties(propGroup) {
    var c, prop;

    // Iterate over the specified property group's properties
    for (c = 1; c <= propGroup.numProperties; c++) {
    prop = propGroup.property(c);
    if (prop.propertyType === PropertyType.PROPERTY) // Found a property
    {

    expressionFix(prop);

    } else if ((prop.propertyType === PropertyType.INDEXED_GROUP) || (prop.propertyType === PropertyType.NAMED_GROUP)) {
    // Found an indexed or named group, so check its nested properties
    scanPropGroupProperties(prop);
    }
    }
    }

    function expressionFix(prop) {
    if (prop.canSetExpression === true) {
    if (prop.expressionEnabled === true) {

    var curExp = prop.expression;
    curExp = curExp.replace(oldWord, newWord);
    prop.expression = curExp // updates old expression with new words
    }
    }
    }

    I used the recursive property function from redefinery to loop through the properties: https://www.redefinery.com/ae/fundamentals/properties/

  • Try using the .moveBefore() method.

    var myLayers, myComp;
    myComp = app.project.activeItem;
    myLayers = myComp.selectedLayers; // array of selected layers

    var newSolid = app.project.activeItem.layers.addSolid([0, 1, 0], myLayers[0].name + " - Solid", myComp.width, myComp.height, myComp.pixelAspect, myComp.duration);
    newSolid.label = 9;

    newSolid.moveBefore(myLayers[0]); // moves new Solid before first selected Layer

  • Try: pixel_size.selection.text === “1px”

    Like this:

    win=new Window("palette","The Fluent Shadow",undefined,{resizeable:true,independent:false,minimizeButton:false,maximizeButton:false,resizeable:false,});
    but_1=win.add("button",[20,60,120,80],"Fluent Shadow");
    but_1.helpTip="Select a layer";
    pixel_size=win.add("dropdownlist",[20,20,120,42] ,["1px","2px","3px","4px","6px","8px","9px","12px","16px","24px","32px","48px","64px","80px","96px",""]);
    pixel_size.selection = 0;
    pixel_size.helpTip="Choose your Shadow size";
    win.center();
    win.show();

    but_1.onClick = function(){

    if(pixel_size.selection.text === "1px"){
    alert("1px");
    }

    if(pixel_size.selection.text === "2px"){
    alert("2px");
    }

    if(pixel_size.selection.text ==="3px"){
    alert("3px");
    }

    }

  • James Ronan

    March 26, 2018 at 11:13 am in reply to: “Scripting” Add keyframe to all path shape

    You would need a recursive function to loop through each layers properties and groups etc.

    It’s a bit rough, but try this:

    // Selected Layers
    var myLayers = app.project.activeItem.selectedLayers;

    //Loop through selected layers
    for (var i = 0; i < myLayers.length; i++) { myLayer = myLayers[i]; //Check if layer Shape Layer if (myLayer instanceof ShapeLayer) { //Find the contents var myContents = myLayer.property("Contents"); // Apply Function to Shapes contents propertySearch(myContents); } // End of If statement } // End of for loop. function propertySearch(a) { //Loop through first set of properties for (var j = 1; j <= a.numProperties; j++) { // Loop through second set to find previous property group for (var k = 1; k <= a.property(j).numProperties; k++) { // Check its a shape if (a.property(j).property(k) == a.property(j).property("ADBE Vector Shape")) { a.property(j).property(k).addKey(1); // add key } // End of Check // Repeat function. Recursively propertySearch(a.property(j).property(k)); } // End of K loop } // end of J for loop } // End of Function.

  • James Ronan

    February 21, 2018 at 2:56 pm in reply to: Update “statictext” on UI

    I’m not entirely sure what your trying to do… But here is an example of static text changing values when a slider is moved.

    var w = new Window ("dialog", "test",undefined,{}); // create window

    var slider = w.add("Slider",undefined); // create slider
    slider.value = 50; // set intital value as 50

    var staticText = w.add("StaticText",undefined,"50"); //Create static text

    slider.onChanging = function() { //create onchanging event for the slider that updates the staticText everytime there is a change
    var percentage = slider.value;
    staticText.text = percentage.toString();
    }

    w.show(); // show window

Page 3 of 3

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