This may be a something I skipped over in my search, but can anyone show me how to add an item to a layer using a JavaScript Adobe Illustrator script?
Also, are there any good resources for learning how to write scripts?
Thanks.
Well, that's two questions really, the first one, here's a sample to move the selected objects to a different layer named new_layer:
var docSelected = app.activeDocument.selection;
var targetLayer = app.activeDocument.layers["new_layer"];
for (s = 0; s < docSelected.length; s++) {
myPath = docSelected[s];
myPath.move(targetLayer, ElementPlacement.PLACEATBEGINNING);
}
The second questions, there's no great resource for learning scripting, but there's plenty of info on the web and on pdf on the adobe website.
Scriptographer - One of the best resources, with tutorials, samples, etc..
Adobe - Manuals in pdf format from adobe
Readthedocs - Wiki with a lot of info for scripting
Medium - A very very basic intro to scripting in illustrator
move
this allows you move the object to specific position in hierarchy. And yes the name may be bad since its ambigious as to wether it moves in space or hierarchy