5 Replies Latest reply on Aug 16, 2011 6:32 AM by csm_phil

    Find script label on object inside of another object.

    Gonterman1201 Level 1

      I have a graphic inside of a box the graphic has a script label. I would like to reference it and its parent but.

      var myAsset=myDocument.pageItems.item("Logo"); does not work. I am wondering if using allPageItems might work however, I have not made anything that has worked yet. Like var myAsset=myDocument.allPageItems.PageItem("Logo"); If there are any ideas about this I would appreciate the help.

        • 1. Re: Find script label on object inside of another object.
          csm_phil Level 4

          Hi Gonterman,

           

          Can you please try this JS Code.

           

          This code is select the page Items of "Logo"

          var myDoc = app.activeDocument;
          for (i=0; i<myDoc.spreads.length; i++){
               try{
                    myDoc.spreads[i].pageItems.item("Logo").select();
                    }catch(e){};
                    }
          

           

           

          This code is select the Graphics frome of "Logo"

           

          var myDoc = app.activeDocument;
          var myGrapic = myDoc.allGraphics;
          for (i=0; i<myGrapic.length; i++){
               var myArt = myGrapic[i];
               try{
                    alert(myArt);
                    if(myArt.label=="Logo"){
                         app.select(myArt);
                         }
                    }catch(e){};
               }
          

           

          thx

          csm_phil

          • 2. Re: Find script label on object inside of another object.
            Gonterman1201 Level 1

            I tried both scripts. They were both unsuccessful in finding the label. I appreciate the help though. The object inside the box would be a child of the box I am wondering if pageItems addresses this. It would be great if I did not have to dig through every item in the document to find this label. When the item is by itself unnested it's label is easy to read.

            • 3. Re: Find script label on object inside of another object.
              Gonterman1201 Level 1

              var myDocument = app.activeDocument;
              var mySprd = myDocument.spreads.length;
                  for (var myCounter=0; myCounter<=(mySprd-1); myCounter++){
                     
                     
                          try{
                              currLabel=myDocument.pageItems.item(myCounter).label;
                              alert(currLabel);
                              }
                          catch(e){alert("didn't happen")};
                        }

               

              If I just have the box with the object with the label inside it I get a return that is empty which makes me think that its finding the object but is not returning the label name. Any thoughts?

              • 4. Re: Find script label on object inside of another object.
                csm_phil Level 4

                Hi Gonterman,

                 

                I think you expect this, Otherwise can you please post the snapshot what you want exact?

                 

                var myDocument = app.activeDocument;
                var mySprd = myDocument.spreads.length;
                    for (var I=0; I<=(mySprd-1); I++){
                       
                       
                            try{
                                //currLabel=myDocument.pageItems.item(I).label;
                                              currLabel=myDocument.pageItems.item(I).contents;
                                alert(currLabel);
                                }
                            catch(e){alert("didn't happen")};
                          }
                

                 

                 

                thx

                csm_phil

                1 person found this helpful
                • 5. Re: Find script label on object inside of another object.
                  Gonterman1201 Level 1

                  var myDoc = app.activeDocument;
                  var myGrapic = myDoc.allPageItems;
                  for (i=0; i<myGrapic.length; i++){
                       var myArt = myGrapic[i];
                       try{
                            //alert(myArt);
                            if(myArt.label=="Logo"){
                                 app.select(myArt);
                                 }
                            }catch(e){alert("didn't happen")};
                       }

                  When I switched to allPageItems it worked. Thanks for all of your help!