2 Replies Latest reply on Oct 30, 2013 11:37 AM by benjaminPease

    How can I add a library asset to a specific master spread?

    benjaminPease

      Hello! I am new to the forums and rather new to javascript as it relates to indesign so I apologize if this is rudimentary.

      I am building a script that automates new document creation for our company and have run into a problem with placing library assets.

      I want to add a library asset to a specific master page by name, but I cannot find a way to do this.

      I can get assets to place into my document with this:

                  var t = app.libraries.item(0);

                  var libTapeStrip= t.assets.itemByName('Tape Strip');

                  var myTapeStrip = libTapeStrip.placeAsset(myDocument);

      However, the asset is being placed on a master spread that I had previously added to the document. It seems to be the active or front most spread because when the script is complete and I create a new window that spread is what is displayed with the asset on it.

      I would like to place the asset on another master spread, but placeAsset() only accepts documents and text boxes. I have also looked on a way to bring the master spread I want to the front, but cannot find this either.

      If anyone can lead me in the right direction I would appreciate it!!

      Thanks,

      Ben

        • 1. Re: How can I add a library asset to a specific master spread?
          Laubender Adobe Community Professional & MVP

          @Benjamin – You could make the spread (or the page) where you want to place that asset the "activeSpread" or "activePage", place the asset and then go back to the old active one.

           

          Something like this:

          (Here I assume that you want to place your asset on a master spread named "A-Master" and the asset is the first in the one and only library file that is open.)

           

          var myDocument = app.documents[0];
          var myMaster = app.documents[0].masterSpreads.itemByName("A-Master");
          var myLibrary = app.libraries[0];
          var myAsset = myLibrary.assets[0];
          
          var myOLDActiveSpread = myDocument.windows[0].activeSpread;
          
          myDocument.windows[0].activeSpread = myMaster;
          
          myAsset.placeAsset(myDocument);
          
          myDocument.windows[0].activeSpread = myOLDActiveSpread;
          

           

          Uwe

           

          Message was edited by: Laubender

           

          Message was edited by: Laubender [Nothing edited in the code.]

          • 2. Re: How can I add a library asset to a specific master spread?
            benjaminPease Level 1

            @Laubender

             

            Thank you!

            It works well. I realized I was trying to manipulate the window without adding one until after I was placing the asset.

            I appreciate your time and help!

             

            -Ben