• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Is there a way to createPath() from script

Guest
Dec 31, 2017 Dec 31, 2017

Copy link to clipboard

Copied

I love the new createPath() method in CC 2018.  However, I'm not seeing a mechanism to modify or create paths from a script.  Am I missing it?

thanks,

Clay

Views

2.4K

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Deleted User
Jan 07, 2018 Jan 07, 2018

Yes, I'm pretty well traveled on using createPath() in expressions since it came out in October, but createPath() doesn't exist in scripting (extendScript).  The original question was to utilize the same behavior in a script, which I've figured out since, using the shape object.  For example, here's one I use to flip a path horizontally (while keeping the vertices in the same relative position so the shape doesn't flip when animated but instead morphs into the reversed shape, if that makes sense

...

Votes

Translate

Translate
LEGEND ,
Dec 31, 2017 Dec 31, 2017

Copy link to clipboard

Copied

Scripts use a different syntax and distinguish between masks, shape layers and motion paths. thoise functions have been there for eons. I suggest you actually study the scripting guide or freely avialable script examples.

Mylenium

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

Mylenium - Do you know any good scripting guides for createPath I'm trying to learn this as well.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

@sillybomb

I was expecting an actual createPath() function or something similar, but it doesn't exist in scripting.  The way to do this with scripts is the same as any other property in regards to reading and setting it (using property.value, property.setValue, property.valueAtTime(time, evaluate), etc.).  However, you need to set a path value using a shape object.  So, you create and manipulate a shape in your script (or "get" it from an existing path property) and then set the target path property to that shape object.

for example:

-------

var myShape = new Shape();

    

myShape.vertices = [[0, 100], [100, 100], [100, -100], [0, -100]];

myShape.inTangents = [[0, 0], [0, 0], [0, 0], [0, 0]];

myShape.outTangents = [[0, 0], [0, 0], [0, 0], [0, 0]];

myShape.closed = true;

myPathProperty.setValue(myShape);

-------

There is a section for "shape object" in this handy scripting guide...

Welcome to the After Effects Scripting Guide! — After Effects Scripting Guide 0.0.1 documentation

Hope that helps,

Clay McAvoy

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

Hi Clay

I was playing around with it a bit last night

I think you might be able to get what you want by creating the arrays like you have

a = [[0, 100], [100, 100], [100, -100], [0, -100]];

createPath(a,inTangents = [], outTangents = [], is_closed = true);

then you can create the array points any way you like, using for loop or any method of math-magic.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

Yes, I'm pretty well traveled on using createPath() in expressions since it came out in October, but createPath() doesn't exist in scripting (extendScript).  The original question was to utilize the same behavior in a script, which I've figured out since, using the shape object.  For example, here's one I use to flip a path horizontally (while keeping the vertices in the same relative position so the shape doesn't flip when animated but instead morphs into the reversed shape, if that makes sense). There may be more direct ways to code it but it works.

function flipPath() {

    if (activeItem != null && activeItem instanceof CompItem) {

        var selectedProps = activeItem.selectedProperties;

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

            if (selectedProps.name == "Path") {

                var prop = selectedProps;

                var p = prop.value;

                var myShape = new Shape();

                sVerts = p.vertices;

                sIns = p.inTangents;

                sOuts = p.outTangents;

                numVerts = myVerts.length;

                lastVert = numVerts - 1;

                 

                for (i = 0; i <= lastVert; i++) {

                    r = lastVert + 1 - i;

                    if (i == 0) r = 0;

  

                    myVerts = [-sVerts[0], sVerts[1]];

                    myIns = [-sOuts[0], sOuts[1]];

                    myOuts = [-sIns[0], sIns[1]];

                }

               

                myShape.vertices = myVerts;

                myShape.inTangents = myIns;

                myShape.outTangents = myOuts;

                myShape.closed = true;

                prop.setValue(myShape);

            }

        }

    }

}

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Participant ,
Jan 07, 2018 Jan 07, 2018

Copy link to clipboard

Copied

LATEST

my mistake sorry! was thinking of expression scripting only

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines