Question
How to create a new layer with a specific name and set its color in Illustrator?
This seems to work a little differently than in InDesign.
I can't figure out which line is causing the problem.
var d = app.activeDocument;
var items = d.selection;
var item = d.selection[0];
var sel = items;
//layer name and color
var ln = "Text";
var col = [249, 138, 9];
//If no layer is specified, a new layer will be created.
var myLayer = d.layers.getByName(ln);
var lsl = app.activeDocument.layers.length;
if (!myLayer.isValid) {
var myLayer = app.activeDocument.layers.add({ name: ln, layerColor: col });
}
//move select to myLayer
for (i = 0; i < sel.length; i++) {
sel[i].moveToEnd(myLayer);
}
