Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Adding an expression to a path

  • Adding an expression to a path

    Posted by Nick Hill on January 29, 2024 at 11:00 pm

    I can’t work out the right object name for a path I’ve created, which I need to add an expression to. Here’s the code I’ve got:

    </p><p> function createShape(targetComp) {</p><p> return targetComp.layers.addShape();</p><p> }</p><p> function createShapeGroup(shape) {</p><p> return"Contents").addProperty("ADBE Vector Group");</p><p> }</p><p></p><p></p><p> function createPath(group) {</p><p> return"Contents").addProperty("ADBE Vector Shape - Group");</p><p> }</p><p>[...]</p><p> var comp = getActiveComp();</p><p> var shp = createShape(comp);</p><p> = ("Curve");</p><p> var curvgrp = createShapeGroup(shp);</p><p> = ("CurveGrp");</p><p> var curv = createPath(curvgrp);</p><p></p><p></p><p>

    This works, and adds a path in a group called CurveGrp, on a shape layer called Curve.

    But how do I add an expression to this path? I’ve tried these options, and none of them work:

    </p><p>curv.content("Path 1").expression = "[...]";</p><p>curv.content("Path").expression = "[...]";</p><p>curv.path.expression = "[...]";</p><p> curv.content("ADBE Vector Shape").expression = "[...]";<br></p><p></p><p></p><p>

    Nick Hill replied 1 month ago 2 Members · 5 Replies
  • 5 Replies
  • Nick Hill

    January 29, 2024 at 11:01 pm

    I should clarify – this is an AE script rather than an expression.

  • Dan Ebberts

    January 29, 2024 at 11:14 pm

    Try this one:"Path").expression = "value";
  • Nick Hill

    January 30, 2024 at 9:56 am

    Thanks Dan. That doesn’t work though sadly, neither does"Path 1").expression =...

    The hierarchy on the layer is Contents > CurveGrp > Path 1 > Path, if that helps.

  • Dan Ebberts

    January 30, 2024 at 4:45 pm

    That’s surprising because I’m running your code and it works for me:

    function getActiveComp(){
    var theComp = app.project.activeItem;
    if (theComp == undefined){
    var errorMsg = localize("$$$/AE/Script/CreatePathNulls/ErrorNoComp=Error: Please select a composition.");
    return null
    return theComp
    function createShape(targetComp) {
    return targetComp.layers.addShape();
    function createShapeGroup(shape) {
    return"Contents").addProperty("ADBE Vector Group");
    function createPath(group) {
    return"Contents").addProperty("ADBE Vector Shape - Group");
    var comp = getActiveComp();
    var shp = createShape(comp); = ("Curve");
    var curvgrp = createShapeGroup(shp); = ("CurveGrp");
    var curv = createPath(curvgrp);"Path").expression = "value";
  • Nick Hill

    January 30, 2024 at 8:48 pm

    So weird. I just tried that again and it didn’t work. I did, however, make it work using a slightly hacky workaround, going from further back up the tree:

    </p><p>cg ="Contents").property("CurveGrp").property("Contents");<br>"Path 1").property("Path").expression = "value";</p><p></p><p>

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