ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

Paint effect stroke shape to Shape layer shape via script

COW Forums : Adobe After Effects Expressions

<< PREVIOUS   •   FAQ   •   VIEW ALL   •   PRINT   •   NEXT >>
JuanLuis Vich
Paint effect stroke shape to Shape layer shape via script
on Apr 19, 2018 at 12:15:04 am

IWhen working with paint stroke effect, I usually like to paste the path info to a shape layer's path (as easy as go to the paint stroke path, then copy, and go to the shape layer path and paste.
BUT I'm trying to automate that a bit via scripting, so when the script is executed, it automatically copies that info of the stroke path value and paste into the shape layer's path value.
I was reading a bit here at the redefinery site but Im totally stuck, because I don't know how to use the stored data in the paintStroke array he mentions about, and paste into the shapePathData of a new created shape

(this is the code from the Redefinery article, just in case you can't click at the link)

// given:
// layer = Layer object, and the layer can have effects applied
var selectedPaintBrushes = new Array(); // Store brush strokes in an array
var effects ="Effects"); // Look for layers that can have effects
if (effects !== null)
var effect, paintStrokes, paintStroke;
// Iterate over all effects on the layer
for (var i = 1; i <= effects.numProperties; i++)
effect =;
if (effect.matchName === "ADBE Paint") // Look for Paint effects
// Get PropertyGroup containing the strokes
paintStrokes ="ADBE Paint Group");
// Iterate over the brush strokes
for (var j = 1; j <= paintStrokes.numProperties; j++)
// Store only selected strokes in the array
paintStroke =;
if (paintStroke.selected)
selectedPaintBrushes[selectedPaintBrushes.length] = paintStroke;
// The selectedPaintBrushes array now contains the list of selected paint brush strokes
// in top-to-bottom order

do you have any ideas?


Return to posts index

Santi Agustí
Re: Paint effect stroke shape to Shape layer shape via script
on Apr 25, 2018 at 5:10:30 am

this post recalls me to an old quick adaptation I made of the exquisite Redefinery Script that converted masks to shapes, to make it work with paint brushes and shape layers. As I was in an animation project rush and I needed a quick tool for converting brushes paths to shape layers, I only could scratch the surface of the script, and I ended up copy-pasting the paths by hand.
The thing is, having this adapted script as a basis, maybe you can do the copypaste via scripting, copying from the brush path property array to the newly shape paths generated.
Im totally lost on that, so I can help more than that, I don't know how to go from the original paths, store their values, and paste on the duplicated paths in the shape layer ☹

Making that work would be a really handy tool I think! Any advice?

here is the quick script you can start from. Now it goes thru all the brushes of a solid, and makes a duplicated of them on a newly created shape layer, buuuuuuut they are empty (is handy to recreate the hierarchy btw)

// quick and awufully adapted code from the original rd_MasksToShapes from the great

app.beginUndoGroup("duplicate paintGroups to shape layer groups");
var activeComp = app.project.activeItem;
var myLayers = activeComp.selectedLayers[0];

// Get PropertyGroup containing the strokes
var paintGroup ="ADBE Effect Parade").property("ADBE Paint").property("ADBE Paint Group");

// Create an empty shape layer
var suffix = " the Shape";
var shapeLayer = activeComp.layers.addShape(); =,31-suffix.length) + suffix;

var shapeLayerContents ="ADBE Root Vectors Group");
var shapeGroup = shapeLayerContents; //.addProperty("ADBE Vector Group");

// Iterate over the paints layer's paints, converting their paths to shape paths

for (var m=1; m<=paintGroup.numProperties; m++)
// for (var m=1; m<=paintGroup.numProperties; m++)

// Get paint info
paint =;
paintShape ="ADBE Paint Shape");

// Create new shape path using paint info
shapePathGroup = shapeGroup.addProperty("ADBE Vector Shape - Group"); =;
shapePath ="ADBE Vector Shape");


Sorry I can't help more, but as your question was something similar to what I did, maybe is useful as a start until some real scripting expert can drive you onto a better direction 😃

Return to posts index

JuanLuis Vich
Re: Paint effect stroke shape to Shape layer shape via script
on Apr 27, 2018 at 1:04:53 pm

I have no idea about how to achieve the copypaste thing via scripting, but as a hierarchy replicator as you said, it works :-D

Return to posts index

<< PREVIOUS   •   VIEW ALL   •   PRINT   •   NEXT >>
© 2019 All Rights Reserved