• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

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

New Here ,
Aug 24, 2020 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

1.1K

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
community guidelines
Adobe
LEGEND ,
Aug 24, 2020 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.

Votes

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
community guidelines
Community Expert ,
Aug 24, 2020 Aug 24, 2020

Copy link to clipboard

Copied

LATEST

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

Votes

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
community guidelines