3 Replies Latest reply on Jun 13, 2017 11:02 AM by cmoke73

    Find objects by title/name

    cmoke73 Level 1

      Hi everybody.

      In a large document I like to let my script search for objects of the same kind. They should be found and pushed into a layer (I have to create).

      My Idea was to search by the name or by the title of that object. It is an Illustrator-created-button.  In the link-menue one can find those informations about. But how can I reach those information via script?

      It doesn´t work with:




      Any idea?

        • 1. Re: Find objects by title/name
          Loic Aigon Level 2

          Given that myDoc is properly referenced and object_name the actual name of the item then there are no reason your commend wouldn't work to the exception of the forgotten closing parenthesis.

          • 2. Re: Find objects by title/name
            cmoke73 Level 1

            There is a closing parenthesis in the original script.


            But I´m not sure "itemByName" means THAT name (from the meta-data)

            • 3. Re: Find objects by title/name
              cmoke73 Level 1

              After a while, I resolved the problem by myself... that´s more interresting


              var myDoc = app.activeDocument,
              myName="this is a name",
              //myPages = myDoc.pages.everyItem(),
              myLayers = myDoc.layers,
              myRectangles = myDoc.rectangles;
              app.doScript(selectObjects, ScriptLanguage.JAVASCRIPT, undefined, UndoModes.ENTIRE_SCRIPT, "moving things");
              function selectObjects(){
                  if( !myDoc.layers.itemByName(myName).isValid ){
                      mySpecialLayer = myDoc.layers.add({name:myName, layerColor: UIColors.GOLD});
                  else{alert("There is already a level with the name.")};
                  for(var i=0;i<myRectangles.length;i++){
                  if(myRectangles[i].graphics.length == 1) {
                      if(myRectangles[i].graphics[0].itemLink.name == "Button1.ai" || myRectangles[i].graphics[0].itemLink.name == "Button2.eps"){