Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Shape layer property customization via ExtendScript

  • Shape layer property customization via ExtendScript

    Posted by Krishna Moorthy on November 8, 2016 at 1:02 pm

    Hi, I have to access the size position and roundness values of a shape layer so that I can change those values to the ones I desire.

    The code snippet I tries is:

    var shapeLayer = pipComp.layers.addShape(); // adding a shape layer to the pipComp
    var contents = shapeLayer.property("ADBE Root Vectors Group"); // Accessing the contents of the shape layer
    var shapeRect = contents.addProperty("ADBE Vector Shape - Rect"); // Adding a rectangle to the shape layer
    var shapeFill = contents.addProperty("ADBE Vector Graphic - Fill");
    var rectSize = shapeLayer.property("ADBE Vector Rect Size");
    var rectPosition = shapeLayer.property("ADBE Vector Rect Position");
    var rectRoundness = shapeLayer.property("ADBE Vector Rect Roundness");
    rectSize.setValue([600, 400]);
    rectPosition.setValue([0.0, -90]);
    rectRoundness.setValue(10);

    ESTK throws an error stating, “null is not an object” at this line

    rectSize.setValue([600, 400]);

    and the code terminates execution. How can I solve this to achieve what I am looking for. Kindly, Help!!

    Thanks in advance,
    Krishna

    Billy Sides replied 8 years, 5 months ago 3 Members · 2 Replies
  • 2 Replies
  • Dan Ebberts

    November 8, 2016 at 1:45 pm

    This should work:

    var pipComp = app.project.activeItem;
    var shapeLayer = pipComp.layers.addShape(); // adding a shape layer to the pipComp
    var contents = shapeLayer.property(“ADBE Root Vectors Group”); // Accessing the contents of the shape layer
    var shapeRect = contents.addProperty(“ADBE Vector Shape – Rect”); // Adding a rectangle to the shape layer
    var shapeFill = contents.addProperty(“ADBE Vector Graphic – Fill”);
    shapeRect = contents.property(“ADBE Vector Shape – Rect”); // adding fill invalidates shapeRect
    var rectSize = shapeRect.property(“ADBE Vector Rect Size”);
    var rectPosition = shapeRect.property(“ADBE Vector Rect Position”);
    var rectRoundness = shapeRect.property(“ADBE Vector Rect Roundness”);
    rectSize.setValue([600, 400]);
    rectPosition.setValue([0.0, -90]);
    rectRoundness.setValue(10);

    Dan

  • Billy Sides

    December 13, 2017 at 7:38 pm

    Does anyone know how to put this path in a group object so I can transform it with the group transforms. I’m trying to set the position of it.

    var sVerts= [[-4.66796875,-4.614013671875],[-4.66796875,-1.584716796875],[4.701171875,-1.584716796875],[8.44921875,1.823486328125],[8.44921875,3.798095703125],[4.701171875,7.206298828125],[-4.66796875,7.206298828125],[-8.44921875,3.798095703125],[-8.44921875,3.387939453125],[-5.3125,2.809814453125],[-5.3125,4.512939453125],[5.283203125,4.512939453125],[5.283203125,1.208251953125],[-4.048828125,1.208251953125],[-7.833984375,-2.199462890625],[-7.833984375,-3.797607421875],[-4.048828125,-7.206298828125],[4.498046875,-7.206298828125],[8.283203125,-4.072998046875],[8.283203125,-3.729248046875],[5.248046875,-3.082275390625],[5.248046875,-4.614013671875]];
    var sITans= [[0,0],[0,0],[0,0],[0,-2.7265625],[0,0],[2.86328125,0],[0,0],[0,2.693359375],[0,0],[0,0],[0,0],[0,0],[0,0],[0,0],[0,2.728515625],[0,0],[-2.83203125,0],[0,0],[0,-2.51806640625],[0,0],[0,0],[0,0]];
    var sOTans = [];
    logoShapeLayer = activeItem.layers.addShape();
    logoShapeLayer.name="S Path";
    sShapeGroup = logoShapeLayer.property("ADBE Root Vectors Group");
    sShapeGroup.addProperty("ADBE Vector Shape - Group");
    logoShapeGroup.addProperty("ADBE Vector Graphic - Fill");

    var sShape = new Shape();
    sShape.vertices = sVerts;
    sShape.inTangents = sITans;
    sShape.outTangents = sOTans;
    sShape.closed = true;

    sShapeGroup.property(1).property("ADBE Vector Shape").setValue(sShape);

    -bsides

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