13 Replies Latest reply on Sep 25, 2014 11:08 AM by ursuss

    Auto update files that have "different layers than the imported version" ?

    uDesign Level 1

      Hello all,

       

      Is there a way to auto update all links that have modified layer options?

       

      I have a lot of illustrator files which have a lot of layers in them, I import each file into indesign and use "object layer options" to toggle layers on/off.

      I then duplicate the object in indesign and change the object layer options to toggle a new layer on.

      When I'm done, on average I will have about 100 linked file which will be used 5 times with differernt layers toggled on.

      Updating modified links is not a hassle but if I add, rename, remove, or change the layer order of the orginal file, I get the following error when updating:

       

       

      "The file xxxx has different layers than the imported version. The link will be updated with the source file's current layer visibiltiy setttings."

       

      update_layers.png

       

      I have to keep clicking ok for each time I used the same file with a different layer showing is time consuming.

      Is there a way of updating my indesign file without having to hit "ok" for each link when the modified linked file has different layers?

       

      I am on a Mac and any help would be greatly appericated.

       

      Thank you all.

        • 1. Re: Auto update files that have "different layers than the imported version" ?
          Jump_Over Level 5

          Hi,

           

          All you wrote you do - it means - script does?

          (since you are on scripting forum)

           

          If yes try to toggle between:

           

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;

          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;

           

          rgds

          • 2. Re: Auto update files that have "different layers than the imported version" ?
            uDesign Level 1

            Hey, thanks for the reply!

             

            Sorry, I should have been more clear and I apologize ahead of time if I posted to the wrong section.

             

            I do not have a script for any of the above.

            I actually do not know anything about scripting and it intimidates me

             

            Currently, I am doing everything manually.

             

            Adding files and toggling layers on and off is fine and needs to be done manually.

             

            Each Illustrator files = to a styles

            Each style has multiple colors (some styles have 2 colors other may have 30+)

            Each color is on its own layer (each layer is named the colors name)

             

            Other people have access to the illustrator files.

            They add, delete, rename layers.

             

            When we goto update our indesign files, we get the above error and need to manually click "ok" to each change.

            Once inside indesign, any file we clicked "ok" on will need to have its object layer options fixed because indesign turned all layers on again.

             

            This ends up being a lot of clicks just to get into the file so we can fix the layer options again.

            I was looking for help / a script / a plugin / advice / solution to the above problem.

             

            I would love it if indesign remembered which layer I had toggled on, regardless of layer order or number of layers but I don't think this is possible?

             

             

            Thanks again!

            • 3. Re: Auto update files that have "different layers than the imported version" ?
              Jump_Over Level 5

              Hi,

               

              Is possible, I think. Even much more.

              Imagine this (in short):

              - you have an .indd file with all those images updated to proper link and layers.

              - you run a script, which could name every graphic box in your doc (i.e. using linked file name) and would fill its script label with active layer's name which is ON. You can see a Script Labels panel to see these values.

              - later on, if some links need to be modified - you run a script which could do it reading those values to set a proper properties.

               

              It could works this way, I think...

              • 4. Re: Auto update files that have "different layers than the imported version" ?
                uDesign Level 1

                If it could be done, that would be fantasic!

                • 5. Re: Auto update files that have "different layers than the imported version" ?
                  Jump_Over Level 5

                  Hi,

                   

                  This one should do a 1st part:

                   

                  myDoc = app.activeDocument;
                  myObj = myDoc.splineItems.everyItem().getElements();
                  var arr = new Array(), currLayers;
                  for (var k = 0; k < myObj.length; k++) {
                      if (myObj[k].graphics[0].isValid && myObj[k].graphics[0].itemLink.name.match(/\.ai$/) ) {
                      myObj[k].name = myObj[k].graphics[0].itemLink.name;
                      currLayers = myObj[k].graphics[0].graphicLayerOptions.graphicLayers;    
                      arr = [];
                      for (var i = 0; i < currLayers.length; i++)
                          if(currLayers[i].currentVisibility)
                              arr.push(currLayers[i].name);
                      myObj[k].label = arr.join();
                      }
                  }
                  

                   

                  check if it works with your doc.

                  all boxes filled with .ai should be named (layer panel)

                  all boxes script label should be filled with graphic layer name/names (script label panel)

                   

                  rgds

                  • 6. Re: Auto update files that have "different layers than the imported version" ?
                    uDesign Level 1

                    Wow it worked!

                     

                    Tested on a file with 590 links. As long as the objects are not grouped, the script adds the layer label.

                    If more than one layer is being used for the object, script adds all layers being used.

                     

                    Increditable.

                    • 7. Re: Auto update files that have "different layers than the imported version" ?
                      Jump_Over Level 5

                      hi,

                       

                      In case of catch grouped boxes it should be modified:

                       

                      myDoc = app.activeDocument;
                      myObj = myDoc.allGraphics;
                      var arr = new Array(), currLayers;
                      for (var k = 0; k < myObj.length; k++) {
                          if (myObj[k].itemLink.name.match(/\.ai$/) ) {
                          myObj[k].parent.name = myObj[k].itemLink.name;
                          currLayers = myObj[k].graphicLayerOptions.graphicLayers;    
                          arr = [];
                          for (var i = 0; i < currLayers.length; i++)
                              if(currLayers[i].currentVisibility)
                                  arr.push(currLayers[i].name);
                          myObj[k].parent.label = arr.join();
                          }
                      }
                      

                       

                      before 2nd step describe what modification can be done in .ai files by users, pls

                      rgds

                      • 8. Re: Auto update files that have "different layers than the imported version" ?
                        uDesign Level 1

                        Awesome, label for grouped object now works with above code.

                          

                        Users are able to do the following to Illustrator files:

                          

                        • Make new layer(s)
                        • Rename old layer(s)
                        • Re-arrange layer order
                        • Delete layer(s)
                        • Not sure if it's relevant but some files also contain "template" layers which are used for revision notes.
                        • (if you double click a layer in illustrator, you can change to template which keeps it from being printed or showing in indesign)

                         

                         

                        Each time one of the above is done, object layer options reverts back to toggling all layers on and we have to manually click okay for each time the changed object is used.

                         

                        In a file that has 500+ links, this can be a lot of clicks.

                         

                         

                        Thanks again!

                        • 9. Re: Auto update files that have "different layers than the imported version" ?
                          Jump_Over Level 5

                          Hi,

                           

                          Check this for the 2nd step:

                           

                          myDoc = app.activeDocument;
                          myObj = myDoc.allGraphics;
                          var arr = new Array(), currLayers, check;
                          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                          for (var k = 0; k < myObj.length; k++) {
                              if (myObj[k].itemLink.name.match(/\.ai$/) ) {
                              myObj[k].itemLink.update();
                              myRefresh (k);    
                              arr = myObj[k].parent.label.split(",");
                              o: for (var j = 0; j < currLayers.length; j++) {
                                  for (var i = 0; i < arr.length; i++)             
                                      if(currLayers[j].name == arr[i]) {
                           //               currLayers[j].currentVisibility = true;    // this could be switched off
                           //               myRefresh (k);     // this could be switched off
                                          continue o;
                                      }
                                          currLayers[j].currentVisibility = false;
                                          myRefresh (k);  
                              }
                              }
                          }
                          app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
                          
                          function myRefresh (number) {
                              myObj = myDoc.allGraphics;
                              currLayers = myObj[number].graphicLayerOptions.graphicLayers;
                              }
                          

                           

                          If some layer was renamed ==> can't see the way to update it this way.

                          You have to relink it manually, I am afraid.

                           

                          enjoy

                          • 10. Re: Auto update files that have "different layers than the imported version" ?
                            uDesign Level 1

                            Hey Jump_over!

                             

                            Thanks for all your help.

                             

                            The above code does seem to work on small files but when I tested it on a file that had 50+ pages and 500+ links, indesign kept freezing/locking up and I had to force quit out.

                             

                            Not sure what it's hanging on.

                             

                            Also, would it be possible to have a script update links?

                             

                            dont_update_link.png

                             

                            Instead of updating, users can click "don't update links" and then run a script that would update all links without user interaction.

                            This way if layers have been changed, they wouldn't have to click/confirm each change?

                             

                             

                            Thanks again!

                            • 11. Re: Auto update files that have "different layers than the imported version" ?
                              Jump_Over Level 5

                              Hi,

                               

                              There is a progress bar included:

                               

                              myDoc = app.activeDocument;
                              myObj = myDoc.allGraphics;
                              var arr = new Array(), currLayers, check;
                              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.neverInteract;
                              
                                  // Progress bar -----------------------------------------------------------------------------------
                                  var progressWin = new Window ("window", "Layer Updater");
                                  var progressBar = progressWin.add ("progressbar", [12, 12, 350, 24], 0, myObj.length.length);
                                  var progressTxt = progressWin.add("statictext", undefined, "I am updating " + myObj.length.toString() + " files");
                                  progressTxt.bounds = [0, 0, 340, 20];
                                  progressTxt.alignment = "left";
                                  progressWin.show();
                                  var count = 1;
                                  // Progress bar -----------------------------------------------------------------------------------
                              
                              for (var k = 0; k < myObj.length; k++) {
                                  if (myObj[k].itemLink.name.match(/\.ai$/) ) {
                                  myObj[k].itemLink.update();
                                  myRefresh (k);    
                                      // Progress bar -----------------------------------------------------------------------------------
                                          progressBar.value = count;
                                          progressTxt.text = String("Current file:  - " + myObj[k].itemLink.name + " (" + count + " from " + myObj.length + ")");
                                      // Progress bar -----------------------------------------------------------------------------------
                                  arr = myObj[k].parent.label.split(",");
                                  count++;
                                  o: for (var j = 0; j < currLayers.length; j++) {
                                      for (var i = 0; i < arr.length; i++)             
                                          if(currLayers[j].name == arr[i]) {
                                              continue o;
                                          }
                                              currLayers[j].currentVisibility = false;
                                              myRefresh (k);  
                                  }
                                  }
                              }
                                  // Progress bar -----------------------------------------------------------------------------------
                                  progressWin.close();
                                  // Progress bar -----------------------------------------------------------------------------------
                              
                              app.scriptPreferences.userInteractionLevel = UserInteractionLevels.interactWithAll;
                              
                              function myRefresh (number) {
                                  myObj = myDoc.allGraphics;
                                  currLayers = myObj[number].graphicLayerOptions.graphicLayers;
                                  }
                              

                               

                              Script will update links (the way you wrote) but won't relink to a missing files.

                               

                              rgds

                              1 person found this helpful
                              • 12. Re: Auto update files that have "different layers than the imported version" ?
                                uDesign Level 1

                                Hey jump_over

                                 

                                The progress bar helped a lot.

                                I have to do more testing with the script, it works, but works slow when I use it on a large file.

                                 

                                Will post after I've tested more.

                                 

                                Thanks again for all your help!

                                • 13. Re: Auto update files that have "different layers than the imported version" ?
                                  ursuss Level 1

                                  Well, I use a simple and somewhat childish solution: I keep the Enter key pressed until it imports all the files It works like wonder.