Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions How do I add an Ellipse shape to a Comp with script?

  • How do I add an Ellipse shape to a Comp with script?

    Posted by Mattias Svendsen on September 27, 2011 at 9:46 am

    How do I create an Ellipse shape in a Comp with script? Can I access and create an Ellipse property with parameters or do i have to create it point by point?
    Can’t find anything about the syntax of creating shapes so any hints or examples would be great. Ive understood that you can create path points with Arrays but i havn’t found an example.

    Fail //shapeLayer.property(“Contents”).addProperty(“Ellipse”);
    Fail //shapeLayer.property(“Contents”).addProperty(“Ellipse 1”);

    Mattias Svendsen replied 14 years, 10 months ago 2 Members · 4 Replies
  • 4 Replies
  • Dan Ebberts

    September 27, 2011 at 10:29 pm

    Like this:


    var myComp = app.project.activeItem;

    var myEllipseSize = [100,200];
    var myFillColor = [0.5, 0.5, 1.0];

    var myShapeLayer = myComp.layers.addShape();
    var myShapeLayerContents = myShapeLayer.property("ADBE Root Vectors Group");
    var myShapeGroup = myShapeLayerContents.addProperty("ADBE Vector Group");
    var myEllipse = myShapeGroup.property("ADBE Vectors Group").addProperty("ADBE Vector Shape - Ellipse");
    myEllipse.property("ADBE Vector Ellipse Size").setValue(myEllipseSize);
    var myShapeFill = myShapeGroup.property("ADBE Vectors Group").addProperty("ADBE Vector Graphic - Fill");
    myShapeFill.property("ADBE Vector Fill Color").setValue(myFillColor);

    Dan

  • Mattias Svendsen

    September 28, 2011 at 9:37 am

    Excellent! Exactly what i needed to know. Thank you, Dan.

    Is there any official information about the property ADBE Root Vector Groups? Google returns only one hit. The aftereffectscs3_scripting_guide.pdf mentions it tangentially as “This is the same as using a shape tool in “Tool Creates Shape” mode. Tools automatically add a vector group that includes Fill and Stroke as specified in the tool options.” This is all i’ve found. How did you learn of it?

    I need several rings so this is what i use. I’ll wrap it in a function later.
    var myEllipseSize = [70,70];
    var myStrokeWidth = [4];
    var myStrokeColor = [1, 0, 0];

    var shapeLayer2 = compShot.layers.addShape();
    var shapeLayer2Contents = shapeLayer2.property("ADBE Root Vectors Group");

    var myShapeGroup = shapeLayer2Contents.addProperty("ADBE Vector Group");
    var myEllipse = myShapeGroup.property("ADBE Vectors Group").addProperty("ADBE Vector Shape - Ellipse");
    myEllipse.property("ADBE Vector Ellipse Size").setValue(myEllipseSize);
    var myShapeStroke = myShapeGroup.property("ADBE Vectors Group").addProperty("ADBE Vector Graphic - Stroke");
    myShapeStroke.property("ADBE Vector Stroke Width").setValue(myStrokeWidth);
    myShapeStroke.property("ADBE Vector Stroke Color").setValue(myStrokeColor);

    var myShapeGroup = shapeLayer2Contents.addProperty("ADBE Vector Group");
    var myEllipse = myShapeGroup.property("ADBE Vectors Group").addProperty("ADBE Vector Shape - Ellipse");
    myEllipse.property("ADBE Vector Ellipse Size").setValue(myEllipseSize);
    var myShapeStroke = myShapeGroup.property("ADBE Vectors Group").addProperty("ADBE Vector Graphic - Stroke");
    myShapeStroke.property("ADBE Vector Stroke Width").setValue(myStrokeWidth);
    myShapeStroke.property("ADBE Vector Stroke Color").setValue(myStrokeColor);

    Keywords: Create Add ADBE Vector Ellipse Graphic Shape Group Stroke addProperty Script

  • Dan Ebberts

    September 28, 2011 at 11:10 am

    I learned it mostly by using Jeff Almasol’s rd_GimmePropPath script (https://www.redefinery.com/ae/view.php?item=rd_GimmePropPath) to get the match names of all the shape properties.

    Dan

  • Mattias Svendsen

    September 28, 2011 at 11:55 am

    Gimme Prop Path should be a permanent part of After Effects! Thanks for pointing out this invaluable tool for scripters 🙂

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