Copy link to clipboard
Copied
Hi, I would like to copy comp to comp, like screenshoots.How I can do that in my code. Thank you for advice.
Copy link to clipboard
Copied
var mainComp = app.project.item(1); // Main comp
var layerCollection = mainComp.layers;
comps2Add = [];
var newWidth = 0;
comps2Add[0] = app.project.item(2); // screen1
comps2Add[1] = app.project.item(3); //screen2
comps2Add[2] = app.project.item(4); // screen3
for(i=0; i<comps2Add.length; i++){
layerCollection.add(comps2Add); // adding layers to comp
newWidth = newWidth+comps2Add.width;
}
mainComp.width = newWidth;
for(l=2; l<= mainComp.layers.length; l++){
var posX =mainComp.layer(l-1).transform.position.value[0]+mainComp.layer(l).width;
var posY = mainComp.layer(l).transform.position.value[1];
mainComp.layer(l)("ADBE Transform Group")("ADBE Position").setValue([posX,posY]);
}
Copy link to clipboard
Copied
I'm adding screen like that.
var customBTN = myPanel.grp.getBatchFolderButton;
customBTN.text = "Create/Sync Template";
customBTN.textPen = customBTN.graphics.newPen (customBTN.graphics.PenType.SOLID_COLOR, whitePalette, 1);
customBTN.fillBrush = customBTN.graphics.newBrush( customBTN.graphics.BrushType.SOLID_COLOR, bluePalette);
customBTN.onClick = function (){
with( this ) {
app.project.items.addComp("Master",screenResolution,608,1.0,10,60);
app.project.items.addFolder("Rotation Screens");
app.project.items.addComp("Screen 1",1280,720,1.0,10,60);
app.project.item(1).layers.addSolid([50,50,50], "Background", 1280 , 720, 1.0, 180);
app.project.item(3).layers.addSolid([0,0,0], "Background", 1280 , 720, 1.0, 180);
app.project.item(3).layers.addText("1"); // adding layer Screen 1
var customPlus = myPanel.grp.myButtonPlus; // add the new screen
customPlus.textPen = customPlus.graphics.newPen (customBTN.graphics.PenType.SOLID_COLOR, whitePalette, 1);
customPlus.fillBrush = customPlus.graphics.newBrush( customBTN.graphics.BrushType.SOLID_COLOR, bluePalette);
customPlus.onClick = function (){
with( this ) {
app.project.item(1).remove();
screenResolution = screenResolution + 408;
app.project.items.addComp("Master",screenResolution,608,1.0,10,60);
count++; // screen number
screenLocation++;
var myComp = app.project.items.addComp("Screen "+count,1280,720,1.0,10,60);
app.project.item(screenLocation).layers.addSolid([0,0,0], "Background", 1280 , 720, 1.0, 180);
app.project.item(screenLocation).layers.addText(count); // adding layers Screens
var compToMove = app.project.item(screenLocation); // compositionın yerini tespit ediyor
var folderTarget = app.project.item(2); // folderın yerini tespit ediyor
compToMove.parentFolder = folderTarget; // compositionı folder'ın içine atıyor
// PROBLEM Ä°S HERE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
app.project.item(1).layers.add(app.project.item(screenLocation));
var range = count + 1;
if(range >=3){
app.project.item(1).layers.add(app.project.item(range));
range++;
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
var compShape = app.project.item(1).layers.addShape();
compShape.name = "Rotation Screen Control";
}// end with
} // end customPlus
var compToMove = app.project.item(3); // compositionın yerini tespit ediyor
var folderTarget = app.project.item(2); // folderın yerini tespit ediyor
compToMove.parentFolder = folderTarget; // compositionı folder'ın içine atıyor
//var myPosition = [-312,110];
//app.project.item(3).layer(1).property("ADBE Transform Group").property("ADBE Position").setValue(myPosition);
}
}