11 Replies Latest reply on Jun 15, 2015 1:07 AM by suneelkv

    Add image link filename to each artboard

    ahendrick1983

      Hello everyone!

       

      I have a document with several artboards. In each artboard is a different linked image. Is there a way to add the linked filename to the bottom of each artboard? Thank you!

        • 1. Re: Add image link filename to each artboard
          Muppet Mark Level 5

          It's possible as long as links are not missing.

          1 person found this helpful
          • 2. Re: Add image link filename to each artboard
            W_J_T Level 4

            Welcome to the forum.

             

            In accordance with others whom have been so generous to me since joining the forum, I messed around and came up with this basic crude example which seems to work and may be a starting point for your efforts. I rarely mess with artboards or placed images but was curious none the less. Thusly I found it rather convoluted, so I thought maybe my attempt may assist you in some way. As Mupput Mark mentioned it will assumedly fail if the link is missing or if the artboard doesn't contain an image, as I didn't bother to factor those conditions in. Instead I based the simple idea off your original threads screen shot of just a single image on each artboard and what you wrote here in your post. Maybe it will help you in some way.

             

            // Basic example of putting placed image names on each artboard
            // underdeveloped and maybe a crude approach ;-)
            
            if (app.documents.length == 0) {
                alert("No Open / Active Document Found");
            } else {
                var doc = app.activeDocument;
                for (var i = 0, l = doc.artboards.length; i < l; i++) {
                    var ab = doc.artboards[i];
                    doc.artboards.setActiveArtboardIndex(i);
                    doc.selectObjectsOnActiveArtboard();
                    var txt = doc.textFrames.add();
                    txt.contents = ab.name + " / Image = " + doc.selection[0].file.name; 
                    txt.textRange.characterAttributes.size = 48;
                    txt.position = [ab.artboardRect[0] + 50, ab.artboardRect[1] - 50];
                    app.activeDocument.selection = false;
                }
            }
            

             

            Likewise if someone can suggest a more concise or better approach I would welcome the education ;-)

            1 person found this helpful
            • 3. Re: Add image link filename to each artboard
              ahendrick1983 Level 1

              W_J_T,

               

              Thank you for your reply and I really appreciate you putting something together. I tried the script but am receiving and error.

               

              Error 21: undefined is not an object.

              Line: 13

               

              ->     txt.contents = ab.name + " / Image = " + doc.selection[0].file.name;

               

              Any thoughts?

               

              If it would be easier for you to test on I could add you to my Google Drive folder with the working files.

               

              Again your input and efforts are greatly appreciated!

              1 person found this helpful
              • 4. Re: Add image link filename to each artboard
                W_J_T Level 4

                Like I previously metnioned:

                W_J_T wrote:

                 

                As Mupput Mark mentioned it will assumedly fail if the link is missing or if the artboard doesn't contain an image, as I didn't bother to factor those conditions in.

                 

                So again, the script assumes you have a linked image on each and every artboard in the document and the link is in fact working and correct. If those two conditions fail to exist you indeed will get errors. If I delete one of the images on one of the arboards I can replicate the same error, that is why I stated and mentioned it originally. In addition if there is a broken, missing link you will receive an error as well.

                 

                • No image on one of the artboards will result in:

                Error: undefined is not an object

                 

                • An image that is not longer present (link broken) will result in:

                Error: There is no file associated with this item

                 

                Both instances as mentioned will not allow the script to work properly.

                 

                Does that help?

                 

                ----

                 

                As a side note, I like how Mark simply saying it was possible was marked helpful, but me writing an actual script to do it was not deamed helpful or correct (ha ha).

                • 5. Re: Add image link filename to each artboard
                  ahendrick1983 Level 1

                  What happened to patience? Thanks for ALL YOUR HELP!

                  • 6. Re: Add image link filename to each artboard
                    W_J_T Level 4

                    You're welcome.

                    ahendrick1983 wrote:

                     

                    What happened to patience?

                     

                    Huh? Rather what happened to sense of humor and simple amusement, I was mostly kidding and jesting (note the ha, ha and smiley). As for patience, well like I mentioned I don't really target artboards or linked images when scripting so actually it took a lot of patience for me to figure out how to write that little script to get it to work.

                     

                    So was one of those two conditions mentioned causing the issue you encountered? Past that does the script now work for your needs? If so, wouldn't the code post be marked "correct" and the follow up be marked "helpful" instead.

                    • 7. Re: Add image link filename to each artboard
                      ahendrick1983 Level 1

                      W_J_T,

                       

                      I was also teasing about the patience comment. I am very new to these forums and I am not used to the dry humor and sarcasm. I have felt a little intimidated and was reluctant to ask for help. But again I thank you.

                       

                      I tested the script on my file and received the error. I tested your code on a new file, only 2 artboards and 2 linked images, and received the same error but artboard 1 linked filename did show up right in the center of the two. See attached screenshot.

                       

                      Screenshot2-01.jpg

                      • 8. Re: Add image link filename to each artboard
                        W_J_T Level 4

                        What version of Illustrator are you using? I use CS5 and everything worked fine otherwise I would have never posted it of course. Sorry its not working for you?

                         

                        As for the errors you're getting I can not replicate that. Unless as stated I make a file that does not meet the two requirements I mentioned above concerning the images, so I am not really sure. Your artboards look pretty small, you can change the text size down from 48 to something smaller. But as to why its not working for you, I am unsure.

                        • 9. Re: Add image link filename to each artboard
                          CarlosCanto Adobe Community Professional & MVP

                          Hi guys, the problem is in fact the text size, the frame is going beyond the artboard width and into the next artboard, so for artboard 2, selection[0] is the text, not the image, the script was developed with either wider artboards or laid out vertically.

                          • 10. Re: Add image link filename to each artboard
                            W_J_T Level 4

                            Yeah I used 48 for the text size because my artboards at the time were 30"x30", so that makes since concerning the selection with the text crossing over the smaller artboards, good call CarlosCanto.

                             

                            I wrote a different version with some basic conditions,  to remove the previous texts, continue if nothing was found on the artboard, but couldn't figure out if there was a way to know if a link is invalid, like checking if .file.name == null or something to avoid "Error: There is no file associated with this item". Like I mentioned in my first post "if someone can suggest a more concise or better approach I would welcome the education" as I never really deal with artboards or placed image items, but was trying to help none the less. ;-)

                            • 11. Re: Add image link filename to each artboard
                              suneelkv Level 1

                              I'm looking exactly similar to this

                               

                              ****

                              I wrote a different version with some basic conditions,  to remove the previous texts, continue if nothing was found on the artboard, but couldn't figure out if there was a way to know if a link is invalid, like checking if .file.name == null or something to avoid "Error: There is no file associated with this item". Like I mentioned in my first post "if someone can suggest a more concise or better approach I would welcome the education" as I never really deal with artboards or placed image items, but was trying to help none the less. ;-)

                              ****

                               

                              Please reply if anybody have answer