1 Reply Latest reply on Jan 30, 2009 11:34 AM by Kasyan Servetsky

    Change name of Layers

    Seth McGraw
      I would like to change the name of the default layer to the result of a dialog entry.

      example: In the dialog the user has the choice of two words, "Silkscreen" or "Litho". Whatever the user chooses I would like the default document layer to be renamed in like. I then will need to call on this layer by name later in script.

      note: Their has been a truckload of stuff already happening on this layer, so creating a layer is not an option at this point.

      Any ideas would be greatly appreciated.
        • 1. Re: Change name of Layers
          Kasyan Servetsky Level 5
          Hi Seth McGraw,

          What do you mean saying 'default layer': the active layer or "Layer 1"?
          The following script renames the active layer.


          var myDoc = app.activeDocument;
          var myListOfLayerNames = ["Silkscreen", "Litho"];

          var myDialog = app.dialogs.add({name:"Select a new name for the layer", canCancel:true});
          var myColumn = myDialog.dialogColumns.add();
          var myPanel = myColumn.borderPanels.add();
          with (myPanel.dialogColumns.add()) {
             var myDD = dropdowns.add({stringList:myListOfLayerNames, selectedIndex:0});
          if (myDialog.show() == true) {
             try { 
                myDoc.activeLayer.name = myListOfLayerNames[myDD.selectedIndex];
             catch(e) {
                alert("Some error occured.");