ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Reffering to the table of vertices

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
Pawel Zelwan
Reffering to the table of vertices
on Jun 29, 2020 at 3:48:18 am

Hello

I have a little trouble with referring to the vertex table. I don't really understand how I should refer to its elements in the loop.

Could I have a merciful hint, please?


var Shape = shapeBaseLayer.property("Contents").addProperty("ADBE Vector Group");
var <b>table</b> = [
[[-1192.11,-65.27],[-1187.12,-66.52],[-1180.67,-73.19],[-1166.08,-76.88]],
[[-1195.97,-63.93],[-1198.11,-56.11],[-1202.12,-55.71],[-1202.29,-54.67]]
];

for (var i = 1; i <= table.length; i++){
var Feature = Shape.property("Contents").addProperty("ADBE Vector Group");
Feature.name = ("Feature " + i);
Feature.property("Contents").addProperty("ADBE Vector Shape - Group");
var myShape = new Shape();
myShape.vertices = <b>table[i]</b>;
myShape.closed = true;
Feature.property("Contents").property(1).property("ADBE Vector Shape").setValue(myShape);
}


This code does not work. And what should it work?

Of course I can do it in this way:


var Feature = Shape.property("Contents").addProperty("ADBE Vector Group");
Feature.name = ("Feature <b>1</b>");
Feature.property("Contents").addProperty("ADBE Vector Shape - Group");
var myShape = new Shape();
myShape.<b>vertices</b> = [[-1192.11,-65.27],[-1187.12,-66.52],[-1180.67,-73.19],[-1166.08,-76.88]];
myShape.closed = true;
Feature.property("Contents").property(1).property("ADBE Vector Shape").setValue(myShape);

var Feature = Shape.property("Contents").addProperty("ADBE Vector Group");
Feature.name = ("Feature <b>2</b>");
Feature.property("Contents").addProperty("ADBE Vector Shape - Group");
var myShape = new Shape();
myShape.<b>vertices</b> = [[-1195.97,-63.93],[-1198.11,-56.11],[-1202.12,-55.71],[-1202.29,-54.67]];
myShape.closed = true;
Feature.property("Contents").property(1).property("ADBE Vector Shape").setValue(myShape);


... but I mean the readability of the code and its separation from the data.

Pawel


Return to posts index

Filip Vandueren
Re: Reffering to the table of vertices
on Jun 29, 2020 at 9:52:04 am

I have not tested your code, ti would take some setting up.
But one thing that jumps out at me is the index "i" should start at 0 to look in your table-array:

myShape.vertices = table[i-1];

Maybe that fixes the whole thing ?



Return to posts index

Pawel Zelwan
Re: Reffering to the table of vertices
on Jun 29, 2020 at 2:41:53 pm

Yes.

myShape.vertices = table[i-1];

I should have thought about the length of the loop.

I insisted, however, that there is certainly something more complicated

Thank you, Filip.

Pawel


Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2020 CreativeCOW.net All Rights Reserved
[TOP]