3 Replies Latest reply on Feb 12, 2014 7:48 AM by Peter Kahrel

    Detecting a layer by name

    tusharde Level 1

      The following code is part of a larger script. I'm trying to detect if the layer "Canons Grid" exists. If it doesn't then create a new layer with that name. This code fails everytime, even if the layer doesn't exist. What am i doing wrong?




      var doc = app.activeDocument;
      var canonLayer;      
            try {
                        canonLayer = doc.layers.itemByName("Canons Grid");
                        canonLayer = doc.layers.add({name: "Canons Grid"});