Highlighted

How to move some group items to another layer in Javascript for Illustrator?

New Here ,
Aug 24, 2020

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! 

TOPICS
Scripting

Views

35

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

How to move some group items to another layer in Javascript for Illustrator?

New Here ,
Aug 24, 2020

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! 

TOPICS
Scripting

Views

36

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Aug 24, 2020 0
Adobe Community Professional ,
Aug 24, 2020

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 24, 2020 2
Adobe Community Professional ,
Aug 24, 2020

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");
    }
}

 

Best regards

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Aug 24, 2020 1