Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions Trying to create a path with an array of positions :/

  • Trying to create a path with an array of positions :/

    Posted by Nick Hill on June 9, 2023 at 12:55 pm

    I’m being obtuse here – this should work surely?

    The setup: I have Null 1 to Null 11 at indices 1-11. I want to use their positions to create a mask on some footage. Here’s the code I’m using on the mask path property:

    let p = [];
    for (i = 1; i <=11; i++) {
    p[i] = thisComp.layer(i).position;
    }
    createPath(p, [], [], true)

    I get the error “argument 1 to createPath must be 2 numbers”. Using this code in the textSource property of a text layer and outputting p.join(‘\r’), I get a string of numbers separated by commas, so the loop is working at least. Array.isArray(p) outputs True. And if I use this as the last line on the path expression, it works:

    createPath([[100,100],[200,100],[200,200]], [], [], true)

    I’ve used this approach before in other (much more complex) code, so I can’t work it out.

    Brie Clayton replied 2 years, 10 months ago 3 Members · 3 Replies
  • 3 Replies
  • Dan Ebberts

    June 9, 2023 at 2:40 pm

    This works for me:

    p = [];
    for (i = 1; i <= 11; i++){
    L = thisComp.layer(i);
    p.push(fromComp(L.toComp(L.anchorPoint)));
    }
    createPath(p,[],[],true)
  • Nick Hill

    June 12, 2023 at 9:32 am

    Amazing – thanks Dan!

  • Brie Clayton

    June 13, 2023 at 2:44 pm

    Thank you, Dan, for this solve!

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