4 Replies Latest reply on Nov 3, 2008 6:35 AM by (Dave_Saunders)

    Loading Layers


      How to load a particular layer from one document to another document through JS Script.

        • 1. Re: Loading Layers
          Level 1
          Presumably, it's the contents of the layer you care about, not just the layer itself.

          There is no "load a layer" command, you'll have to examine the one document (with the layer) and take the necessary steps to create the layer in question in the other document, and then duplicate all the items (guides, pageItems) on the layer from the one to the other. Probably working a spread at a time.

          • 2. Re: Loading Layers
            subhaoviya Level 1
            Hai Dave,

            while am trying to duplicate pageitem from one document into another document,i dont know how to set the array of units as parameter.


            var myitem=app.activeDocument.pageItems[0];



            thanks in advance

            by subha
            • 3. Re: Loading Layers

              I think, you can't duplicate pageItem from one document to another.

              1) You can copy the pageitem from one document, then set another document as active, then pasteinplace.

              2) Select all the page item in a spread, Store in a Library, then set another document as active, then place it

              • 4. Re: Loading Layers
                Level 1
                This script works in CS4. I created two documents and drew a rectangle on the first page of one of them, then ran this simple script:
                myDocs = app.documents;
                for (var j = 0; myDocs.length > j; j++) {
                  if (myDocs[j].pageItems.length > 0) {
                    source = myDocs[j];
                  } else {
                    target = myDocs[j];
                pi = source.pageItems[0];