This is my first time I'm posting, so before all I'd like to thank all the contributors for sharing their knowledge and making this forum a great ressource.
I've been using AfterEffects for ten years now, but I began to script only this summer, and as I am not a programmer, each new script is a long and difficult process for me. But it really worth it and now I'm hooked.
So for the first time I'm asking a little bit of help because I don't know if I'm using the correct method for the goal I want to reach.
Now,what I want to do is to copy some selected masks+all the effects related to these masks (Fill and Stroke effects) and paste them on another layer in another comp. For now, I'm just trying to copy/paste the masks as you can see in the following script.
Code: Select all
var w = new Window ("palette");
cpy = w.add ("button", undefined, "Copy");
pst = w.add ("button", undefined, "Paste");
//copy Masks
cpy.onClick= function() {
app.beginUndoGroup("copyMasksAndFX");
function getSelectedMasks(){
var oneLayer = app.project.activeItem.selectedLayers[0];
var selectedMasks = new Array();
for(i=1; i<= oneLayer.Masks.numProperties; i++){
if(oneLayer.Masks.property(i).selected)
selectedMasks[selectedMasks.length]=oneLayer.Masks.property(i);
}
return selectedMasks;
}
getSelectedMasks();
app.endUndoGroup();
}
//paste Masks
pst.onClick=function() {
app.beginUndoGroup("pasteMasksAndFX");
function createMasks(numMasks) {
var anotherLayer = app.project.activeItem.selectedLayers[0];
var newMasks = anotherLayer.Masks.addProperty("Mask");
newMasks.name=selectedMasks[numMasks].name;
newMasks.maskPath.setValue ( selectedMasks[numMasks].maskPath.value);
newMasks.maskOpacity.setValue(0);
}
for (var i = 0; i < selectedMasks.length; i++){
createMasks(i);
}
app.endUndoGroup();
}
w.show ();