take a look at the sample in the Reference called "Duplicating the active document"
We have managed to use this but we are struggling to split the page items from the page item so we can then ask the layer name?
the sample I mentioned describes how to duplicate all selected objects in a document, using
var docSelected = app.activeDocument.selection;
it is usually not advice to use the selection for this kind of stuff, to work with ALL pageItems in a document use
var allPageItems = app.activeDocument.pageItems;
now if you only want to copy items in a layer you can use either the index number (for instance, top layer index = 0) or the name of the layer (for instance "Layer1"), use this, you don't have to select them
var topLayerPageItems = app.activeDocument.layers.pageItems;
or using the layer name
var Layer1PageItems = app.activeDocument.layers['Layer1"].pageItems;
Thanks for this its has helped.
I am trying to SaveAs on the document I have duplicated the items onto but Illustrator throws up an error message to say that the file may be read-only. Is there something i'm missing.
var FinalFile = new File("Users/macuser/Desktop/FinalFile.ai");
var saveOptions = new IllustratorSaveOptions();
var ai15Doc = new File(FinalFile);
saveOptions.compatibility = Compatibility.ILLUSTRATOR15;
saveOptions.flattenOutput = OutputFlattening.PRESERVEAPPEARANCE;
app.activeDocument.saveAs( ai15Doc, saveOptions );
Check your path:
Try this at first:
var FinalFile = new File("~/Desktop/FinalFile.ai");
where is the file? I can't find it in the "C:\Program Files\Adobe\Adobe Illustrator CS6 (64 Bit)\Scripting\Sample Scripts"
dry yao wrote:
where is the file?
what file are you looking for?
I can't find the the sample in the Reference called "Duplicating the active document".
and, how to duplicating objects in different documents?
it is not a script in the sample scripts folder, look here, page 11
I got it，thanks a lot !!!!