9 Replies Latest reply on May 29, 2013 1:16 PM by Jump_Over

    Help! new to script

    DriveFST

      hi forum!......

       

      I m new to scripting...

       

      I want a small things to do with scripting.

       

       

      I want to select an image (link) placed inside page(0) of document.

       

      my link name. teddy_1.ai. and the location is in desktop (PC);

       

      so....

       

      app.select("~/Desktop/teddy_1.ai");

       

      sorry i'm just tring....

       

      pls help me forum.....

       

      THANKS,

      FST...

        • 1. Re: Help! new to script
          dln385 Level 2

          Since you're new to scripting, I'll point you to some helpful resources.

           

          The Adobe InDesign CS6 Object Model is a fantastic reference. You can browse through everything that ExtendScript has to offer. You'll probably want to go through the Adobe InDesign CS6 Scripting Tutorial to get started with scripting. The Adobe InDesign CS6 Scripting Guide: JavaScript and Adobe CS5 JavaScript Tools Guide are also great resources.

           

          It looks like you'll have to actually find the graphic object in the document before you can select it. To help you get started, try running

           

          var graphics = app.activeDocument.Pages[0].allGraphics;
          for (var i = 0; i < graphics.length; i++) {
                    $.writeln("Name:" + graphics[i].name);
                    $.writeln("Display Name" + (new File(graphics[i].itemLink.filePath)).displayName);
          }
          

           

          and see if you can find your "teddy_1.ai" image.

           

          If it does have a name, you might be able to use something like:

           

          app.activeDocument.links.itemByName("teddy_1.ai");
          

           

          There's also a method

          app.activeDocument.findObject()
          

          but I'm not sure if you could use it for your purpose.

           

          Good luck!

          • 2. Re: Help! new to script
            DriveFST Level 1

            Hi din385;

             

            I tried with your above script;

             

            var graphics = app.activeDocument.Pages[0].allGraphics; for (var i = 0; i < graphics.length; i++) {           $.writeln("Name:" + graphics[i].name);           $.writeln("Display Name" + (new File(graphics[i].itemLink.filePath)).displayName); }

             

            and also like this...

             

            app.activeDocument.links.itemByName("teddy_1.ai").select();

             

            but nothing happens.

             

            I cound not able to select the image

            ("teddy_1.ai").

             

            could you please help me directly.....

             


            • 3. Re: Help! new to script
              Jump_Over Level 5

              Hi,

               

              run this to select image in displayed doc (IF placed and IF so named indeed):

              app.activeDocument.links.itemByName("teddy_1.ai").parent.select();

               

              In case of "first" script it should be a list of every graphics file names written in ESTK console. What do you mean "nothing happens'?

               

              To select image is your script's goal?

               

              There is a basic rule on this forum:  >>complex info is a complex help<<

               

              Jarek

              • 4. Re: Help! new to script
                Laubender Adobe Community Professional & MVP

                @Jarek & DriveFST – this line of code will select the placed image itself.

                Not its graphic container (if THAT is the thing DriveFST likes to do?). The parent of the link is the placed image. The parent of that parent is the graphic container (e.g. a rectangle).

                 

                But what will happen, if the image is placed more times than one?

                 

                Here some more "complex info" ;-)

                 

                Looking for objects by the method itemByName() has the "flaw", that only the first instance of such an object is addressed. By first, I mean the very first time the image is placed in the document.

                 

                If we want to address ALL links with the same name we have to loop through the links collection to filter out the right ones and storing something more than just the name for further use. For that we could use the unique ID number of the link or (maybe*) the unique* ID number of the image on the page or the unique* ID number of the graphic container on the page.

                 

                *Especially for placed Adobe Illustrator files that are manipulated showing different layers on and off, the uniquness of the ID number is not given in the process. At least not for its graphic container.

                *See the following discussions here:
                http://www.indiscripts.com/post/2013/05/indesign-scripting-forum-roundup-4#hd2sb1

                http://forums.adobe.com/message/4920745#4920745

                1 person found this helpful
                • 5. Re: Help! new to script
                  DriveFST Level 1

                  Hi Jarek

                       Jump_Over  

                   

                  Thanks you so much for your advise... The smartest way you have shown me to select the first instance of the link.name.

                   

                  Superb! hereafter i'll place my request in a clear way...

                   

                  thanks so much for the advise Jump_Over.

                  • 6. Re: Help! new to script
                    DriveFST Level 1

                    Hi Laubender,

                     

                    thanks and much thanks to have shown me the good link... I'll make use of it..

                     

                    thanks thanks for the http link....

                     

                    rgds,

                     

                    Chand..

                    • 7. Re: Help! new to script
                      Laubender Adobe Community Professional & MVP

                      @Chand – ahem(!), would you be so kind giving Jarek the 10 points for his answer #3 and not yourself? That would only be fair…

                       

                      Uwe

                      • 8. Re: Help! new to script
                        DriveFST Level 1

                        Hey Laubender,

                         

                        Sorry, sorry.

                        I have did something wrong when applying, as I am not intended to give points to myself..

                         

                        actually the credit should definately goes to "Jarek"_Jump_over.

                         

                         

                        "Many apologise for this Jarek"  THAT HAD HAPPENED BY MISTAKE..

                         

                        AS I'M NEW TO THIS KIND OF RATINGS...

                         

                        SORRY JAREK.....

                         

                        @Chand

                        • 9. Re: Help! new to script
                          Jump_Over Level 5

                          Hi,

                           

                          @Chand

                          From my point of view - everything is OK

                          Hope you go through first reef and will sail now on high seas

                           

                          Jarek