-
Scale selected comps, overwrite selected comps
Found the code I need here: https://www.aenhancers.com/viewtopic.php?t=701
But I just want it to overwrite the selected comps, not create new ones called “resize”. I figured I could just add a section that says mySelection[i].remove(); but this deletes the layers within the new comp and I can’t figure out why. Code is below:
var percent = prompt("Resize factor (percentage):","50");
var mySelection = app.project.selection;
app.beginUndoGroup("scaleSelectedComps.jsx");
for (var i = 0; i < mySelection.length; i++)
{
if (mySelection[i] instanceof CompItem)
{
var compName = mySelection[i].name;
var W = Math.round(mySelection[i].width * percent/100);
var H = Math.round(mySelection[i].height* percent/100);
var pixAsp = mySelection[i].pixelAspect;
var Dur = mySelection[i].duration;
var frRate = mySelection[i].frameRate;
var resizedComp = app.project.items.addComp(compName,W,H,pixAsp,Dur,frRate);
var myLayer = resizedComp.layers.add(mySelection[i]);
myLayer.scale.setValue([percent,percent]);
mySelection[i].remove(); //this should just remove the current selected comp, but instead deletes the layers within that comp, and the new comp created from var ResizedComp is created empty.
}
}
app.endUndoGroup();