3 Replies Latest reply on Nov 6, 2012 12:55 PM by Paul Hough

    Enfocus Switch and indesign Script (JavaScript CS5.5)

    Paul Hough

      I was on here last night asking for help with a center all images/graphics code and got terrific feedback.

       

      Now I have a new problem with the same scrpit, Below is a script that I wrote for relinking broken links. It works like a champ exept when the orignal image/graphic is not the same size of the existing new link. So I added a new part to the code (what i had help with last night) I have bolded the sectioin. 

       

      When I run the scrpit in Indd everything works great. But, when I run the script throught Enfocus Switch the program stalls

      AnyIdeas or sugestions are greatly appreciated.

       

      //////Code Starts Here//////////

       

      app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;

       

      var docs = app.documents;

       

      for (var i = 0; i < docs.length; i++) {

           UpdateAllOutdatedLinks(docs[i]);

      }

      function UpdateAllOutdatedLinks(doc) {

           for (var d = doc.links.length-1; d >= 0; d--) {

                var link = doc.links[d];

                if (link.status == LinkStatus.linkOutOfDate) {

                     link.update();

                }

           }

      }

      app.activeDocument.pages.everyItem().rectangles.everyItem().images[0]. fit(FitOptions.CEN TER_CONTENT);

       

       

      //////// Code Ends Here ////////

        • 1. Re: Enfocus Switch and indesign Script (JavaScript CS5.5)
          Trevorׅ Adobe Community Professional

          Hi again Paul,

           

          I don't know what you mean by "Enfocus Switch " do you mean throw the ESTK script editors run?

          If so you probably have it set to ExtendedScript Tool Kit.

          You can change it manually, or better to include this line at the begging of the script

          #target indesign
          

           

          After rereading your post I highly doubt that this is the solution, but you can try and if not then you can clarify what you mean by the enfocus script.

           

          See also annotations below

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.NEVER_INTERACT;
          
          var docs = app.documents;
          
          for (var i = 0; i < docs.length; i++) { // this "docs" is for all the open documents
               UpdateAllOutdatedLinks(docs[i]);
          }
          function UpdateAllOutdatedLinks(doc) { // You have not declared "doc" without the "s"
               for (var d = doc.links.length-1; d >= 0; d--) {
                    var link = doc.links[d];
                    if (link.status == LinkStatus.linkOutOfDate) {
                         link.update();
                    }
               }
          }
          app.activeDocument.pages.everyItem().rectangles.everyItem().images[0]. fit(FitOptions.CEN TER_CONTENT);
          // this is the active document
          

           

          Regards

          Trevor

          1 person found this helpful
          • 2. Re: Enfocus Switch and indesign Script (JavaScript CS5.5)
            Jump_Over Level 5

            Hi,

             

            If "Enfocus Switch" is a 3rd party task manager Trevor's advice to add

            #target indesign

            definitelly helps to run.

             

            I would modify:

            • docs[i].pages.everyItem().rectangles.everyItem().images[0]. fit(FitOptions.CENTER_CONTENT);

                      should be inside your for_loop (docs[i]).
                      (Centering resized images is good enough for you?)

            • app.scriptPreferences.userInteractionLevel = UserInteractionLevels.INTERACT_WITH_ALL;

                       you should go back to interacting at script's end, I guess.

             

            Jump_Over

            • 3. Re: Enfocus Switch and indesign Script (JavaScript CS5.5)
              Paul Hough Level 1

              Thanks for your help everything is working again!!