5 Replies Latest reply on Jul 23, 2013 5:26 AM by Wander5

    graphics moving to layers: problem

    Wander5

      Hi Forum,

       

      While I'm moving graphics to the another layer.  The desgin (placement of the images) get spoiled. 

       

      The backmost of the image is brought forward to frontmost and hiding all the frontmost image.

       

      Suppose, if the backmost image is page full width and page full height, when the script is run, it comes front most and hiding all the images.

       

      So, how could i maintain the apperences of the images placed sameas, after moved to the "Image Layer" through script.

       

      var allDocumentGraphics = app.activeDocument.allGraphics;

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

          if (allDocumentGraphics[i].constructor.name == "Image") {

             

      allDocumentGraphics[i].parent.itemLayer = "Images"}}

       

      thanks forum.

        • 1. Re: graphics moving to layers: problem
          Jump_Over Level 5

          Hi,

           

          Notice that sendToBack() and bringToFront() methods work within one (parent) layer.

          Each layer is a "independent area" to place pageItems on it.

           

          Thats why moving item between layers means changing its 3D position regarding to another items.

          So final item 3D position depends on:

          - how your layer is located regarding to other layers in THIS document

          - how your item is located regarding to other items on THIS layer.

           

          Jarek

          • 2. Re: graphics moving to layers: problem
            Wander5 Level 1

            Hi Jarek,

             

            I have images that are placed one above and below in a same layer and that need to be transferred to other layer.

             

            so -how your item is located regarding to other items on THIS layer. (as you said here).

            the items are located in order to move in a same order to other layer.

             

            and now the item above is moved first and then the below item is moved, and that makes the design to spoil.

            how can i maintain the 3D position depends on the

             

            - how your item is located regarding to other items on THIS layer.

             

            and then moved to

             

            - other layers in THIS document

            • 3. Re: graphics moving to layers: problem
              Wander5 Level 1

              Hi Jarek!!

               

              I tried with this,, and now the images seems to be stacked within a same layer in a same placement order. As it was before..

               

              var allDocumentGraphics = app.activeDocument.links;

               

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

               

                  //if (allDocumentGraphics[i].constructor.name == "Image") {

               

                    

               

              allDocumentGraphics[i].parent.parent.itemLayer = "Images"}//}

              • 4. Re: graphics moving to layers: problem
                Jump_Over Level 5

                Hi,

                 

                If a placement order is a final items order ==> that's OK

                so last placed item is on the top.

                 

                What if they were rearranged after placement?

                To keep pageItem's real 3D location you have to iterate through doc layers

                and move graphic.parents in backward order:

                 

                mDoc = app.activeDocument,
                mLayers = mDoc.layers.everyItem().getElements(),
                mLayer = mDoc.layers.item("Image"),
                mSpItems;
                
                for (k = mLayers.length-1; k >= 0; k--) {
                     mSpItems = mDoc.layers[k].splineItems.everyItem().getElements();
                     for (i = mSpItems.length-1;  i >= 0; i--) 
                          if (mSpItems[i].graphics[0].constructor.name == "Image")
                               mSpItems[i].itemLayer = mLayer;
                     }
                

                 

                Jarek

                • 5. Re: graphics moving to layers: problem
                  Wander5 Level 1

                  Thanks you so much Jarek,,,

                   

                  I'll test it and come back in another thread, to give you more benefit in points..