Question
Duplicate layer in Illustrator
trying to duplicate a layer in Illustrator using javascript. Found copyArtToLayer function on this community. But cannot seem to get it to work. Even tried to place the items using
ElementPlacement.PLACEATEND as the second paramter to the duplicate command. If I can't do this in javascript, is there another method to copy layer with all of its contents to a new layer. Thank you.
#target Illustrator
var sourceLayer = doc.layers.getByName('txtpntLetter');
var destinationLayer = doc.layers.add();
destinationLayer.name = 'txtPathLetter';
copyArtToLayer(sourceLayer,destinationLayer);
function copyArtToLayer(srcLay, destLay) {
var reLock = srcLay.locked ? true : false;
var reHide = !srcLay.visible ? true : false;
srcLay.locked = false;
srcLay.visible = true;
var item;
for(var x = srcLay.pageItems.length -1; x>=0;x--) {
item = srcLay.pageItems;
item.duplicate(destLay);
}
srcLay.locked = reLock ? true : false;
srcLay.visible = reHide ? false : true;
}
