Skip to content

Instantly share code, notes, and snippets.

@msongz
Last active May 31, 2018 16:49
Show Gist options
  • Save msongz/5b6159855ea2ce0f255be2a546dbe9a4 to your computer and use it in GitHub Desktop.
Save msongz/5b6159855ea2ce0f255be2a546dbe9a4 to your computer and use it in GitHub Desktop.
//songz meng
//github.com/msongz
//2018.05.30
var comp = app.project.activeItem;
var sl = comp.selectedLayers;
app.beginUndoGroup("shapes from texts")
//first deselect all selected layers
for (var i = 0; i < sl.length; i++) {
sl[i].selected = false;
}
//select layer one by one from selected layers and run the main code 3781
for (var n = 0; n < sl.length; n++) {
sl[n].selected = true
app.executeCommand(3781)
// new shape layer would being selected, which will prevent the code running correct.
var nsl = comp.selectedLayers;
for (var x = 0; x < nsl.length; x++) {
// so make all the layers deselected
nsl[x].selected = false
}
}
// keep the old and new layer tidy
for (var y = 0; y < sl.length; y++) {
sl[y].moveToBeginning();
}
app.endUndoGroup();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment