Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions “Butt Cap” to “Round Cap” with a Script (But it doesn’t work)

  • “Butt Cap” to “Round Cap” with a Script (But it doesn’t work)

  • Vincenzo Imbimbo

    January 31, 2022 at 3:31 pm

    Hi guys! I don’t know what i’m doing wrong, this should be working, anyone can help me?

    I’m trying to change the “Butt Cap” of selected shape layers to “Round Cap” but i can’t figure it out why is not working, here is the code:

    var project = app.project;

    var comp = project.activeItem;


    app.beginUndoGroup("Process");

    var myLayers = comp.selectedLayers;

    var myLayer;

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

    myLayer = myLayers[i];

    if (myLayer instanceof ShapeLayer){

    var myContents = myLayer.property("ADBE Root Vectors Group");

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

    myContents.property(j).property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Shape - Group").property("ADBE Vector Shape").property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Line Cap").setValue(2);

    }

    }

    }

    app.endUndoGroup();

  • Vincenzo Imbimbo

    January 31, 2022 at 5:37 pm

    I make it work but only for 1 shape element of each shape layer, i want it to work in any shape layer no matter how much elements it has inside the Groups.

    This is what it works:

    var project = app.project;

    var comp = project.activeItem;

    app.beginUndoGroup("Process");

    var myLayers = comp.selectedLayers;

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

    var myContents = myLayers[i].property("ADBE Root Vectors Group").property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Line Cap").setValue(2);

    }

    app.endUndoGroup();

    And this is what i’m doing trying to work through all the properties (i want it to work in any scenario):

    var project = app.project;

    var comp = project.activeItem;

    app.beginUndoGroup("Process");

    var myLayers = comp.selectedLayers;

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

    var myContents = myLayers[i].property("ADBE Root Vectors Group");

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

    myContents.property(j).property("ADBE Vector Group").property("ADBE Vectors Group").property("ADBE Vector Graphic - Stroke").property("ADBE Vector Stroke Line Cap").setValue(2);

    }

    }

    app.endUndoGroup();

  • Filip Vandueren

    February 2, 2022 at 2:33 pm

    Hi Vincenzo,

    since you can’t be sure of the exact “path” to the Line Cap property (it can be embedded into a shapegroup, there could be multiple paths/shapes/rectangels etc, each with multiple strokes…) I think you need to go through each property recursively and if it’s the right one, apply the value.

    Something like this:

    var project = app.project;

    var comp = project.activeItem;

    app.beginUndoGroup("Process");

    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 Stroke Line Cap") {

    subProp.setValue(2);

    }

    }

    }

    }

    app.endUndoGroup();

Viewing 1 - 3 of 3 posts

Log in to reply.

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