Copy link to clipboard
Copied
I'm working on a script to move some group items to another layer automatically using Javascript for Illustrator 2020. I can't find much script samples. Anyone can help? Thank you!
Copy link to clipboard
Copied
This snippet would move the first page item of "BACK TEXT" layer to the top of "Base" layer. Maybe this will get you started.
var aDoc = app.activeDocument;
var backText = aDoc.layers['BACK TEXT'].pageItems[0];
backText.move(aDoc.layers['Base'], ElementPlacement.PLACEATBEGINNING);
Use "ElementPlacement.PLACEATEND" to move it to the bottom of the target layer.
Copy link to clipboard
Copied
Hi,
The following snippet will help tomove the selected item to layer with name "Layer 2". This will work only if selected item is a groupItem.
var aDoc = app.activeDocument;
if (app.selection.length) {
var _selectedItem = app.selection[0];
if (_selectedItem.typename == 'GroupItem') {
try {
var _layer = aDoc.layers['Layer 2'] //Assuming layer with name Layer 2 exists
_selectedItem.move(_layer, ElementPlacement.PLACEATBEGINNING);
} catch (e) {
alert("Layer with name 'Layer 2' doesn't exists");
}
} else {
alert("Please select groupItem");
}
}