Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trying to add dashes to lines via Scripting (Not working)

  • Trying to add dashes to lines via Scripting (Not working)

    Posted by Vincenzo Imbimbo on April 8, 2023 at 5:11 pm

    Hello guys, i don’t know why my code is not working, anyone can help me?
    I created a button that add dashes to selected shape layers, and it seems to be fine but is not working.

    buttonDashes.onClick = function (){ app.beginUndoGroup("Set Dashes");

    var project = app.project;

    var comp = project.activeItem;

    var myLayers = comp.selectedLayers;

    for (var i = 0; i < myLayers.length; i++){

    tryLineCap(myLayers[i].property("ADBE Root Vectors Group"))

    }

    function tryLineCap(prop) {

    for (var j = 1; j <= prop.numProperties; j++){

    var subProp = prop.property(j);

    if (subProp.numProperties) {

    tryLineCap(subProp)

    } else {

    if (subProp.matchName == "ADBE Vector Graphic - Stroke") {

    subProp.property("ADBE Vector Stroke Dashes").addProperty("ADBE Vector Stroke Dash 1").setValue(20);

    }

    }

    }

    }

    app.endUndoGroup();

    }

    Vincenzo Imbimbo replied 3 years ago 3 Members · 3 Replies
  • 3 Replies
  • Tomas Bumbulevičius

    April 8, 2023 at 5:47 pm

    Vincento – describing what does not work could help to get into the issue without even running the code

  • Dan Ebberts

    April 8, 2023 at 7:19 pm

    I’m not sure about your recursive property navigating function, but going right at it like this works:

    myLayers[i].property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Dashes").addProperty("ADBE Vector Stroke Dash 1").setValue(20);
  • Vincenzo Imbimbo

    May 5, 2023 at 4:49 pm

    Hello Dan!! Thank you for your reply, i tried what you tell me and it works perfectly, but the problem is that i want it to be applied to any selected shape layer (or layers) no matter how many shapes and groups are inside this layer/layers, that’s why i was using that recursive property navigating function but i don’t know how to merge that function with the navigation that you gave me, can you help me? Thanks!

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