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

    Loading Layers

    (subha_oviya) Level 1
      Hi

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

      by,
      Oviya
        • 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.

          Dave
          • 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.

            syntax:

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

            app.activeDocument=app.documents(1)

            myitem.duplicate(?)

            thanks in advance

            by subha
            • 3. Re: Loading Layers
              Level 1
              Subha,

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

              Solution
              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

              Luzzi
              • 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];
                pi.duplicate(target.pages[0]);
                Dave