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

script to access animated mask vertices XY position data

New Here ,
Jul 25, 2011 Jul 25, 2011

hello,

I believe there is a way to extract XY positions of vertices on animated maskShape. I would love to use this extracted data to drive XY positions on several Null objects in another layers. So every Null object is related to different vertex on maskShape. I found an older Rotoscopy script that work in sort of opposite way I need. Is there anything like that out there? Is it even possible to create?


Thanks for your help.
Jr.

TOPICS
Scripting
8.6K
Translate
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
Community Expert ,
Jul 25, 2011 Jul 25, 2011

Here's a simple example that creates a null for each mask vertex. It assumes:

  • The layer with the mask is the first layer in the active comp
  • The number of mask vertices doesn't change
  • The layer isn't parented, rotated, or 3D

{
    var myComp = app.project.activeItem;
    var myLayer = myComp.layer(1);
    var myPath = myLayer.property("Masks").property("Mask 1").property("Mask Path");
    var numVerts = myPath.valueAtTime(myLayer.inPoint,false).vertices.length;
    var myNulls = [];
    var myNull;
    var myVerts = [];
    // create nulls
    for (var i = 0; i < numVerts; i++){
        myNull = myComp.layers.addNull(myComp.duration);
        myNull.name = "Vertex " + (i+1);
            myNulls = myNull;
    }
    var t = myLayer.inPoint;
    var p;
    while (t <= myLayer.outPoint){
        myVerts = myPath.valueAtTime(t,false).vertices;
        p = myLayer.property("Position").valueAtTime(t,false) -
            myLayer.property("Anchor Point").valueAtTime(t,false);
        for (var i = 0; i < numVerts; i++){
            myNulls.property("Position").setValueAtTime(t,p + myVerts);
        }
        t += myComp.frameDuration;
    }
}

It gets a bit more complicated if you're dealing with parenting, rotation and/or 3D. You may need to temporarily add a Point Control with a layer space transform expression to do the space conversion and harvest the result.

Dan

Translate
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
New Here ,
Jul 25, 2011 Jul 25, 2011

hey Dan,

Thanks for the example. I found a solution via TrackerViz 3.1 plugin, however your simple script did a better job somehow. No skipped frames. Thanks again!

Jr.

Translate
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
Advisor ,
Dec 18, 2012 Dec 18, 2012

Having done this, what's the best way to then make a shape with those nulls via a bezier path between them and then be animating the nodes to "draw" the changes to the shape?  Is this possible?  And this manner are we then able to "draw by numbers" in that the nulls have full coordinate controllability?

Translate
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 ,
Feb 23, 2017 Feb 23, 2017
LATEST

Hey Dan. I just wanted to say "thanks"! You're expressions and scripts continue to help me out when I get in a jam.

Translate
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