11 Replies Latest reply on Aug 15, 2013 5:39 AM by Marijan Tompa [tomaxxi]

    Update Links

    dissidently Level 1

      I'd like to update the Links in a document, the moment they become in need of updating.

       

      Ideally whilst InDesign is in the background and a [SAVE] action inside Illustrator causes this to update to be required.

       

      However if that's not possible, then simply invoking the script by [Command + Tab] moving into InDesign... is that able to invoke a script?

       

      If not... I'm guessing the fastest way to do things is still going to be manually with a shortcut assigned to Update Links... what I'm using now.

        • 1. Re: Update Links
          Kasyan Servetsky Level 5

          Here's a simple Update Modified Links script I use in my workflow.

          It updates all modified links in the current document. Just assign a shortcut to it — no need to open Links panel to update links.

          • 2. Re: Update Links
            Vamitul Level 4

            if you want to get fancy and create a autoupdater, you can use AFTER_ATTRIBUTE_CHANGED event listener to look for a change in a link's status property.

             

            http://jongware.mit.edu/idcs5/pc_Link.html#addEventListener

            • 3. Re: Update Links
              dissidently Level 1

              Ok... I assume you two are talking about the Javascript that Indesign and Adobe use.  ExtendScript, I think it's called.

               

              Firstly, it's probably important to understand... I'm trying NOT to goto Indesign.  SO I can keep working Illustrator, and see the updates live on the iPad. 

               

              Rob Day has helped me get most of the way...  http://forums.adobe.com/message/5594570#5594570

               

              Here's what I'm trying to do, I've marked my own comment "helpful", rather cheekily, so you can see what I'm doing, it's live previewng on the iPad (or as near is possible) from Illustrator to Indesign to the iPad.

               

              Take a look at the following code, for an AppleScript effort inside Illustrator, that talks to Indesign from Illustrator, via the OS

               

               

              tell application "Adobe Illustrator"

                  tell document 1

                      save

                  end tell

              end tell

              tell application "Adobe InDesign CS6"

                  tell active document

                      delay 3

                      update every link

                      save

                  end tell

              end tell

               

               

              That PARTIALLY works. 

               

              Two problems

               

              1. It doesn't seem to do a FULL update of the Links.  They're rendered by Indesign in the Proxy quarter resolution (the changes)  and the indicator for Link Update Needed still shows... but the content has actually changed.  However a full resolution doesn't happen without a manual update.

               

              2. I can't find a way to make a keyboard shortcut for invoking this script.  So I have to goto the File>Script menu item everytime, which kind of is slower than the current sequence:

               

              [Command + S] ... [Command + Tab] ... [Command + Option + A] ... [Command + Tab] .... continue working.

               

              // btw my shortcut for update all links is [Command + Option + A]

              • 4. Re: Update Links
                Marijan Tompa [tomaxxi] Level 4

                This could be easily done with idle task.

                 

                Turn auto update on:

                #targetengine tomaxxiTEST
                
                main ();
                
                function main () {
                    var
                        uTask = app.idleTasks.add ( { name: "tomaxxiAUTOupdate", sleep: 1000 } ),
                        uEvent = uTask.addEventListener ( IdleEvent.ON_IDLE, uUpdate, false );
                    
                    alert ( "Auto update modified links is ACTIVATED!" );
                }
                
                function uUpdate ( e ) {
                    if ( app.activeDocument.links.everyItem ().status.toString ().indexOf ( "LINK_OUT_OF_DATE" ) != -1 )
                        app.menuActions.itemByID ( 132633 ).invoke ();
                }
                

                 

                Turn auto update off:

                #targetengine tomaxxiTEST
                
                main ();
                
                function main () {
                    if ( app.idleTasks.itemByName ( "tomaxxiAUTOupdate" ).isValid ) {
                        app.idleTasks.itemByName ( "tomaxxiAUTOupdate" ).removeEventListener( IdleEvent.ON_IDLE, uUpdate, false );
                        app.idleTasks.itemByName ( "tomaxxiAUTOupdate" ).remove ();
                        alert ( "Auto update modified links is DEACTIVATED!" );
                    } else {
                        alert ( "Auto update modified links is NOT ACTIVE!" );
                    }
                }
                

                 

                This is just basic example. It could be extended way more.

                 

                Be aware that this will update ALL links in active document.

                If you switch to another document, it will update all modified links as well.

                 

                Hope this will help you.

                 

                (How to Install a Script in InDesign That You Found in a Forum or Blog Post)

                 

                --

                Marijan (tomaxxi)

                http://tomaxxi.com

                • 5. Re: Update Links
                  Vamitul Level 4

                  Marijan, i think the onIdle doesn't fire (on windows, at least) if indesign is not the active (foreground) app.

                  • 6. Re: Update Links
                    Marijan Tompa [tomaxxi] Level 4

                    You think I would post this without testing?

                    It works just fine here on Win, and should on Mac as well!

                    • 7. Re: Update Links
                      -hans- Level 4

                      Hi,

                       

                      I use onidle-Event for productionprogress-slideshow in a newsroom and while testing on my local machine I recognized that it works even if ID is not frontmost!!!

                      • 8. Re: Update Links
                        dissidently Level 1

                        Ok, let's get the stupid stuff (me) out of the way first.

                         

                        Marijan that might look simple to you... but there's a world of prerequired knowledge I don't have.

                         

                        See how I go here:

                         

                        1. This looks like your making a script to run INSIDE Indesign, right?

                        // I ask because there's apparently 3 ways to do this: a) script in Ilustrator, b) OS X script, c) script in InDesign

                         

                        2. You're taking advantage of InDesign acknowledging, to its self, that it's in an idle state, and then making it check for updates necessary, then performing those updates, then sleeping the script for 1000 time units, right?

                         

                        Next, stuff I have no contextual knowledge of:

                         

                        What is tomaxxiTest, tomaxxiAUTOupdate and uUpdate?

                         

                        Want a super stupid question?

                         

                        Why does function main() exist inside main() ... and how is that even possible?

                         

                        By now you probably realise I know very little (right next to nothing) about scripting in Adobe products)

                         

                        Which it looks like you tried to help with... with that link.  But that link is linked to anything other than http://

                         

                        Marijan, I can't thank you enough for pointing your (clearly) brilliant programming mind at this.  But I'm a very horrid student.  I have none of the pre-requisite knowledge.

                         

                        //one other thing... why do you put spaces after function names and before the brackets ( ) like that all the time?  It's confusing an already befuddled brain

                        • 9. Re: Update Links
                          Marijan Tompa [tomaxxi] Level 4

                          1. This looks like your making a script to run INSIDE Indesign, right?

                          Yes, exactly.

                           

                          2. You're taking advantage of InDesign acknowledging, to its self, that it's in an idle state, and then making it check for updates necessary, then performing those updates, then sleeping the script for 1000 time units, right?

                          Yes, that's right. Time interval is in milliseconds, so 1000 is equivalent to 1 sec. I've noticed some issues when using small update times, so feel free to increase it.

                           

                          What is tomaxxiTest, tomaxxiAUTOupdate and uUpdate?

                          - tomaxxiTest is scripting engine under which the script is run

                          - tomaxxiAUTOupdate is just a idleTask name for easier reference

                          - uUpdate is function which is called to execute the update

                           

                          Why does function main() exist inside main() ... and how is that even possible?

                          It doesn't. main(); is a call for function.

                           

                          Which it looks like you tried to help with... with that link.  But that link is linked to anything other than http://

                          That link explains how to save and execute scripts.

                           

                          one other thing... why do you put spaces after function names and before the brackets ( ) like that all the time?  It's confusing an already befuddled brain.

                          It's just a habit.

                           

                          I've updated first script a bit, so if you are using the old version, update it to this.

                          (added: checking for existing idle task, check for opened documents)

                           

                          #targetengine tomaxxiTEST
                          
                          main ();
                          
                          function main () {
                              if ( app.idleTasks.itemByName ( "tomaxxiAUTOupdate" ).isValid )
                                  alert ( "Auto update modified links already ACTIVATED!" );
                              else {
                                  var
                                      uTask = app.idleTasks.add ( { name: "tomaxxiAUTOupdate", sleep: 3000 } ),
                                      uEvent = uTask.addEventListener ( IdleEvent.ON_IDLE, uUpdate );
                                  alert ( "Auto update modified links is ACTIVATED!" );
                              }
                          }
                          
                          function uUpdate ( e ) {
                              if ( app.documents.length > 0 ) {
                                  if ( app.activeDocument.links.everyItem ().status.toString ().indexOf ( "LINK_OUT_OF_DATE" ) > -1 )
                                      app.menuActions.itemByID ( 132633 ).invoke ();
                              } else {
                                  app.idleTasks.itemByName ( "tomaxxiAUTOupdate" ).removeEventListener( IdleEvent.ON_IDLE, uUpdate, false );
                                  app.idleTasks.itemByName ( "tomaxxiAUTOupdate" ).remove ();
                              }
                          }
                          

                           

                          --

                          Marijan (tomaxxi)

                          http://tomaxxi.com

                          • 10. Re: Update Links
                            Vamitul Level 4

                            Marijan, the link on installing scripts you posted does not work