5 Replies Latest reply on Dec 8, 2018 10:29 AM by Laubender

    SCRIPT INDESIGN CC 2019 MAC / Select all Anchor Object in document

    seanf33852861 Level 1

      Hi all

       

      Looking for a script that lets me select all ANCHORS images in my document or....all images or

       

      Select all images and tag them as IMAGES ( in my tag panel : IMAGES, STORY, ARTIFACT )

       

      Can someone help me out

        • 1. Re: SCRIPT INDESIGN CC 2019 MAC / Select all Anchor Object in document
          payalm68947498 Level 2

          hi sean,

               you can find all images in this way, If you know manually you can create script for this also.

           

          Capture.PNG

          • 2. Re: SCRIPT INDESIGN CC 2019 MAC / Select all Anchor Object in document
            Laubender Adobe Community Professional & MVP

            Hi seanf33852861 ,

            you can only select one anchored object at one time with InDesign.

            Scripting with method select() makes no difference.

             

            What you are able to do: You can address all anchored images in your document.

            That means you can store the reference to all anchored images and do something with them after identifying the ones.

             

            What do you like to do with all anchored images?

            EDIT: Oh. You already answered that. You want to tag them as IMAGES.

             

            Here some code to filter all anchored graphics:

             

            // All graphics of the document stored to variable allGraphicsOfDoc:
            var allGraphicsOfDoc = app.documents[0].allGraphics;
            
            // Now that we stored all graphics of the document in an array we can sort out the ones that are anchored.
            // Would you need all graphics, that means also placed PDFs, AIs, EPS, WMFs? Or only pixel based ones?
            
            // Preparing a container, an array for the results:
            var allAnchoredGraphics = [];
            
            // Looping the allGraphicsOfDoc array to filter the ones we need:
            
            for( var n=0 ; n<allGraphicsOfDoc.length ; n++ )
            {
                // The parent of a graphic is always a graphic frame
                // If the parent of that graphic frame is a character, the graphic frame containing the graphic is anchored:
                if( allGraphicsOfDoc[n].parent.parent.constructor.name == "Character" )
                {
                    allAnchoredGraphics[allAnchoredGraphics.length++] = allGraphicsOfDoc[n];
                }
            };
            
            // Looping the result to do something to the filtered graphics:
            for( var n=0; n<allAnchoredGraphics.length; n++)
            {
                doSomethingWithGraphic( allAnchoredGraphics[n] );
            }
            
            // Change this function to your needs:
            function doSomethingWithGraphic( graphic )
            {
                // Get the name of the item link of the placed graphic
                try{
                $.writeln( graphic.itemLink.name );
                }catch(e){ $.writeln( e.message ) };
            };
            

             

            One could also use a GREP find routine for anchored objects.

            But you may have also anchored objects like text frames, rectangles or other graphic frames without a graphic in your document.

            The allGraphics array may be more to the point.

             

            FWIW: Graphics in graphic cells of a table do not fall under the category "anchored" with the code above.

            If you want to include them we have to change the if condition.

             

            Regards,
            Uwe

            • 3. Re: SCRIPT INDESIGN CC 2019 MAC / Select all Anchor Object in document
              Laubender Adobe Community Professional & MVP

              Should a placed AI graphic be tagged as IMAGE as well?

              Or only pixel based images like PSDs, JPEGs, TIFFs ?

               

              Regards,
              Uwe

              • 4. Re: SCRIPT INDESIGN CC 2019 MAC / Select all Anchor Object in document
                seanf33852861 Level 1

                Awsome!

                If I can select all Images Anchor in all the document that would be awsome!...

                reason : its for accessibility, I have a document that has 800 links, all anchors and they are all in a TABLE.

                So if I can select all the boxes in my document, this will reduce my time of all selecting them as IMAGES, cause the other select as STORY is less time then images, hope I am amking sense....

                • 5. Re: SCRIPT INDESIGN CC 2019 MAC / Select all Anchor Object in document
                  Laubender Adobe Community Professional & MVP

                  seanf33852861  wrote

                   

                  Awsome!

                  If I can select all Images Anchor in all the document that would be awsome!...

                  As I already said:

                  You cannot select more than one anchored object at one time.

                   

                  Are the said 800 linked images anchored in text cells of the table?
                  Or are they inserted in graphic cells?

                   

                  To access all graphics of a table you need the table and the allGraphics array of the table.

                  You would then loop the array and then tag every entry as you wish by using scripting.

                   

                  You could try the autoTag() method if you like to apply the XML tag named "Image".

                  In my German InDesign the auto name for that XML tag will be "Bild".

                   

                  One warning with that method:
                  In case the anchored graphic is in overset you will freeze InDesign.

                  Just tested that with InDesign CC 2019.

                   

                  If you are talking not of XML tags, show how you are tagging a single anchored image using some screenshots.

                   

                  Regards,
                  Uwe