2 Replies Latest reply on Jan 20, 2011 12:08 PM by Haakenlid

    Alert images on layer

    kerosk_inddNew

      Hi Everyone,

       

      I have some documents which has 3 layers. The name of layers are 1. "Question", 2.  "Answer" and 3. "Illustrations".

       

      Some of my images are moved on Question layer. Can I get my images list which are on Question layers.

       

      So that I can move images on illustrations layer. Please provide me the code.

       

      Best,

      Kerosk

        • 1. Re: Alert images on layer
          Mi_D Level 3

          Dear Kerosk,

          try this

          var myDoc=app.activeDocument;

          var myImage=myDoc.allGraphics;

          for (var i=0; myImage.length>i; i++){

          app.select(myImage)

          mySelect=app.selection[0]

          if (app.activeDocument.activeLayer.name=="Q"){

          alert (app.activeDocument.activeLayer.name)

          exit()

          }

          else{}

          }

           

          Mi_D

          • 2. Re: Alert images on layer
            Haakenlid Level 3

            If you just want to move all images on the layer Question to the layer Illustrations, you can do it like this:

             

            var myDoc = app.activeDocument;
            var fromLayer = myDoc.layers.itemByName("Question");
            var toLayer = myDoc.layers.itemByName("Illustrations");
            var myItem;
            for (var n= fromLayer.pageItems.length-1; n>=0; n--){
                 myItem = fromLayer.pageItems[n];
                 if (myItem.contentType == ContentType.GRAPHIC_TYPE){
                      myItem.move(toLayer);
                 }
            }