Copy link to clipboard
Copied
Hi folks,
I'm wondering if there's a way to create/manipulate the contents of shape layers through either the javascript scripting api or the sdk.
I can't find any information about this in each respective documentation.
The underlying problem I have is to import custom vector graphics programmatically (they come as neither ai or svg), but do consist of bezier primitives.
Thank you in advance, Jens
Copy link to clipboard
Copied
Hi Jens,
if you can't use the importer, you can still do something if you know the curves data.
I can't tell you how it would work in the sdk.
In AE ExtendScript framework shapes are instances of Shape(), which are objects with 4 properties (for version < CS6) and slightly more since CS6 (for the feather, but for your purpose you can ignore those properties and leave them undefined):
var shape = new Shape();
shape.vertices = myVerticesData;
shape.inTangents = myInTangentsData;
shape.outTangents = myOutTangentsData;
shape.closed = true/false;
where myVerticesData, myInTangentsData, myOutTangentsData are to be defined by you from your shape data.
You might need to do some sort of conversion if your data don't come out in the same form as AE uses.
They should be arrays of 2D points/vectors ( [[x0,y0], [x1,y1], [x2,y2] ...]) of the same length.
myVerticesData
Apparently shape objects are being watched so you can't modify shape vertices individually like this: shape.vertices
You must set the shape array attributes in one shot as above.
If the inTangents or outTangents arrays are not specified they will default to arrays of [0,0].
Once you have transcripted your shape data into a AE Shape() object, you can use it to set the value of a shape layer path or a mask path.
- For a shape layer it would be like this:
var comp = [the comp you want to work with];
var layer = comp.layers.addShape();
var group = layer.content.addProperty("ADBE Vector Group"); // adds a Group (Empty) to the shape content
var shapeGroup = group.content.addProperty("ADBE Vector Shape - Group"); // adds a (custom) Path to that group
shapeGroup.name = "Imported Shape";
shapeGroup.path.setValue(shape);
If you don't want a group, omit that line and do directly var shapeGroup = layer.content.addProperty("ADBE Vector Shape - Group");
Note: for shape layers you'll probably have to work out the fact that they don't have exactly the same behaviour as bounded layers with respect to coordinates,
so you'll have to translate all vertices.
- For a mask:
var comp = [the comp you want to work with];
var layer = comp.layers.addSolid([1,0,0], "Imported Shape", comp.width, comp.height, comp.pixelAspect, comp.duration);
var group = layer.property("ADBE Mask Parade"); // equivalently: var group = layer.mask;
var shapeGroup = group.addProperty("ADBE Mask Atom");
shapeGroup.name = "Imported Shape";
shapeGroup.maskPath.setValue(shape);
Xavier.
Copy link to clipboard
Copied
Thank you for the quick an comprehensive answer, that helped - and I was already worrying that it's not possible to access and manipulate path data.
Copy link to clipboard
Copied
I have worked on this in detail now and want to thank you again, really comprehensive and correct answer.
I'm now able to export a user-entered and positioned text from a WPF application straight into AE. That's pretty awesome and not nearly as difficult as I thought it would be.
Get ready! An upgraded Adobe Community experience is coming in January.
Learn more