Skip to main content
Inspiring
October 22, 2017
Answered

Get Path

  • October 22, 2017
  • 1 reply
  • 659 views

Hi

When I do this it will draw a line, but the alert line will break the script:

var shapeLayer = comp.layers.addShape();

shapeLayer.name = "Shape Layer";

var shapeGroup = shapeLayer.property("Contents").addProperty("ADBE Vector Group");

shapeGroup.name = "Group";

var pathShape = new Shape();

pathShape.vertices = [[0,0],[100,100]];

pathShape.closed = false;

var pathGroup = shapeGroup.property("Contents").addProperty("ADBE Vector Shape - Group");

pathGroup.property("Path").setValue(pathShape);

var pathStroke = shapeGroup.property("Contents").addProperty("ADBE Vector Graphic - Stroke");

pathStroke.property("Color").setValue([0,0,0]);

pathStroke.property("Stroke Width").setValue(4);

alert(pathGroup.property("Path").value);

Why is that? Problem is, I need to send that path value to another function and when I do that it breaks.

Thanks,

Jakob

This topic has been closed for replies.
Correct answer UQg

When you add new children to an indexed group, previous references to its children become invalid:

after you add pathStroke, pathGroup is invalid. You need to reassign it.

var contents = shapeGroup.property("Contents");

var pathGroup = contents.property(contents.numProperties-1);     // that's after you have added the stroke

alert(pathGroup.property("Path").value);

1 reply

UQg
UQgCorrect answer
Legend
October 22, 2017

When you add new children to an indexed group, previous references to its children become invalid:

after you add pathStroke, pathGroup is invalid. You need to reassign it.

var contents = shapeGroup.property("Contents");

var pathGroup = contents.property(contents.numProperties-1);     // that's after you have added the stroke

alert(pathGroup.property("Path").value);

Inspiring
October 22, 2017

AAh yes. Forgot about that. Gets me everytime! Thanks.