1 Reply Latest reply on Jun 3, 2013 11:00 AM by pixxxel schubser

    Layer getByName

    Ghoulfool Level 1

      Hiya

       

      app.activeDocument.activeLayer = app.activeDocument.artLayers.getByName("Layer 1");
      

       

      I found out that the getByName layer method will grab the topmost layer if there are multiple layers named the same. Since you can have layers named the same (unlike path names) would the best practice for this to check for unique names before doing such a call?

       

      Cheers

        • 1. Re: Layer getByName
          pixxxel schubser MVP & Adobe Community Professional

          The topmost layer is always layers[0]

           

          getByName() get the next layer which is having the correct name. There is normally no need to search, if there any other layers with the same name exists.

           

          Why do you have layers with the same name? In this case you should check for unique names before you use this method. One way to do this: check your layers with REGEX like search() or match() whether the same name is used in the document multiple.