0

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.

2
  • 1
    The layer, and other objects has a method called 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
    – joojaa
    Commented Jun 16, 2020 at 6:11
  • 1
    All space moves are called transforms... So not exactly normal reading comprehension. And no there are no good resources to learn scripting. But again that is because learning scripting is just the same as using illustrator in first place. If you know how to program and use illustrator you know illustrator scripting.
    – joojaa
    Commented Jun 16, 2020 at 6:17

1 Answer 1

2

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..

In github - Quick Intro

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.