8 Replies Latest reply: Sep 11, 2009 8:04 PM by iBabs2 RSS

    An action that deletes all hidden objects

    iBabs2 Community Member

      Hello

      In a constant effort to save and place smaller files...I was wondering if there was a way to script illustrator files so that it deletes all the hidden objects.

      I end up with so many hiden objects in these files, I am sure that would be a great help, if I could set an action either inside of illustrator or through a script to drag and drop files onto to that would delete the hidden files.

      I cannot find any commands on this in the program, so I did not know if it is possible, but I figures I would try.

      thanks!

      babs

        • 1. Re: An action that deletes all hidden objects
          Larry G. Schneider CommunityMVP

          Here's a script that I have to delete hidden layers in a file. It could be reworked to target page items. Remember you can only delete something if it is visible.

           

          --get a sourceFolder that holds the files to process
          set sourceFolder to (choose folder with prompt "Choose a folder with files to process:") as text

           

          -- get a list of files of the files to process in the sourceFolder
          tell application "Finder" to set workingFiles to (every file of folder sourceFolder) as alias list

           


          repeat with aFile in workingFiles
              tell application "Adobe Illustrator"
                  open aFile
                 
                  set currentFile to front document
                 
                  tell application "Adobe Illustrator"
                      set myLayers to every layer of currentFile
                     
                      repeat with i from 1 to count of items in myLayers
                         
                          set myLayer to item i of myLayers
                          set locked of myLayer to false
                         
                          if visible of myLayer is true then
                              set visible of myLayer to false
                          else if visible of myLayer is false then
                              set visible of myLayer to true
                          end if
                         
                      end repeat
                     
                      delete (every layer of currentFile whose visible is true)
                     
                  end tell
                 
                  tell application "Adobe Illustrator"
                     
                      set visible of (every layer of currentFile) to true
                     
                  end tell
                 
                  close currentFile with saving
                 
              end tell
          end repeat

          • 2. Re: An action that deletes all hidden objects
            iBabs2 Community Member

            Hi Larry,

            This script gives a message that the  variable working files is not defined ?

            any thoughts on that one ;-)

            thanks!

            babs

            • 3. Re: An action that deletes all hidden objects
              Larry G. Schneider CommunityMVP

              Where and/or how are you running the script? I just tested it in AICS4 with a folder on my desktop and it worked fine. I had placed the script in the AICS4>Presets>Scripts folder. I just tried it from the script editor and it ran fine from there also.

              • 4. Re: An action that deletes all hidden objects
                iBabs2 Community Member

                Hi Larry....

                Hmmm....I wonder if it has to do with the operating system..

                I am on 10.5 on my laptop using AICS3 and it worked fine.

                In the Office, we are still on 10.4...I wonder if that is what is causing the problem..

                Is that possible?

                thanks!!!

                babs

                • 5. Re: An action that deletes all hidden objects
                  Larry G. Schneider CommunityMVP

                  Shouldn't be a problem. Actually the script was written when I was on 10.4.9 or so. Did you run it from the ScriptEditor at the office or from the application?

                  • 6. Re: An action that deletes all hidden objects
                    iBabs2 Community Member

                    I actually saved it as an .app on my desktop and double clicked it where it asks me to choose a folder.

                    Is there another way I should be doing this??

                    thanks!!!!

                    babs

                    • 7. Re: An action that deletes all hidden objects
                      Larry G. Schneider CommunityMVP

                      Try using

                       

                      Set workingFiles to (every file of folder sourceFolder) as alias list

                      • 8. Re: An action that deletes all hidden objects
                        iBabs2 Community Member

                        Hi Larry.....

                        I won't be able to test this till I am back in my other office and that will not be till next wednesday....

                        I will try it then and let you know if it works ;-)

                        thanks!

                        babs