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

Show / Unhide specific sublayer (with name)

Participant ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

Hello all, can anyone help me

I am trying to unhide/show a specific sublayer using it's name but I always get the message:

 

"Eval Error (#1302): "No such element" in (hid this part for safety) ( [17:undefined] in host 'illustrator-26.064 (main)'.

 

here is the code

 

var doc = app.activeDocument;
app.executeMenuCommand('selectallinartboard');
app.executeMenuCommand('group');
var mesaActiva = app.activeDocument.artboards.getActiveArtboardIndex ();
doc.artboards.setActiveArtboardIndex(mesaActiva);
app.executeMenuCommand('selectallinartboard');
app.executeMenuCommand('cut');
var NewLayer = doc.layers.add();
NewLayer.name = "Center Top";
app.executeMenuCommand('paste');
to_center(doc.artboards[mesaActiva], app.selection[0]);
app.executeMenuCommand('selectallinartboard');
doc.selection[0].translate(249.2979,438.1053);
var myLayers = doc.layers;
for (var i=0; i<myLayers.length; i++) {
    if(myLayers[i].name=='Guides'){
        for (var l = 0; l<myLayers.layers.length; l++) {
            if(myLayers[i].layers[m].name=='G_Left_Chest_Top'){
                myLayers[i].layers[m].visible=true;
            }
               
        }
           
    }
    else{
        alert('Not found');
    }
       
}
   
           
//center on artboard
function to_center(artboard, item){//recibe un id de mesa y un item a centrar
    var artboard_x = artboard.artboardRect[0] + artboard.artboardRect[2];
    var artboard_y = artboard.artboardRect[1] + artboard.artboardRect[3];
    var x = (artboard_x - item.width)/2;
    var y = (artboard_y + item.height)/2;
    item.position = [x, y];//coloca item en posicion
}
TOPICS
How to , Scripting , SDK , Tools

Views

22

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

correct answers 1 Correct answer

Participant , Oct 12, 2022 Oct 12, 2022

Likes

Translate

Translate
Participant ,
Oct 12, 2022 Oct 12, 2022

Copy link to clipboard

Copied

LATEST

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