Copy link to clipboard
Copied
Hi everybody,
i have this script for merging layers "only 2 layers will be merged... adding layer A & layer B", which is also found in indesign scripting guide.
I am trying to merge the infinity layers inside document to single layer.
can any one tweak this script, as per my request.
main();
function main(){
mySetup();
mySnippet();
myTeardown();
}
function mySetup(){
var myDocument = app.documents.add();
myDocument.layers.add();
}
function mySnippet(){
var myDocument = app.documents.item(0);
//<fragment>
//Given a document "myDocument" containing at least two layers...
var myLayerA = myDocument.layers.item(0);
var myLayerB = myDocument.layers.item(1);
myLayerA.merge(myLayerB);
//</fragment>
I tweaked like this.... script runs without error but no result,,, leaving the layers unmerged...
main();
function main(){
mySetup();
mySnippet();
myTeardown();
}
function mySetup(){
var myDocument = app.documents.add();
}
function mySnippet(){
var myDocument = app.documents.item(0);
//Given a document "myDocument" containing infinity layers...
var myLayers = myDocument.activeLayer.everyItem();
myLayers.merge;
}
function myTeardown(){
}
thanks
babylon.
ya super fantastic vamit...
thanks buddy.
Copy link to clipboard
Copied
try:
function main(){
var doc=app.activeDocument;
var lrs=doc.layers.everyItem().getElements(), l=lrs.length;
while (l--){
lrs[0].merge(lrs
); }
alert('Done!\nYou can go outside an play now!');
}main();
Copy link to clipboard
Copied
ya super fantastic vamit...
thanks buddy.