7 Replies Latest reply on Jan 12, 2018 6:59 AM by tmmls

    [CC2018][Os X][JS] Place asset based on a script label

    tmmls Level 1

      Hi,

       

      With this post I would like to ask a question.

       

      I have a library and I would like to place an asset on my document using the script label (not using the item name).

      When looping the library assets, I'm not able to check the label. When checking the label contents, it always seems to be empty.

      When placing the asset manually, the script label is filled in.

       

      Is this a bug ?

       

      Thanx

       

       

      placeAsset();
      
      function placeAsset(){
          var myLib = app.libraries.item("myLibrary.indl");
          var myItem = getItemFromLib(myLib, "import");
          myItem.placeAsset(app.activeDocument);
      }
      
      
      function getItemFromLib(myLib, myLabel){
              for(g = 0; g < myLib.assets.length; g++){
                      var myItem = myLib.assets[g];
                      if (myItem.label == myLabel){   // This doesn't work
                              return myItem;
                      }
              }
      }