3 Replies Latest reply on Sep 9, 2018 8:09 AM by BarlaeDC

    script to generate a setup of layers in indesign

    lister110 Level 1

      Hi, I have used a script in the past to generate a set of pre-defined layers:

      for some reason if I un this AppleScript I get an error now 'Expected end of line but found identifier.' with LayerName highlighted. I can't work out why this has happened now. Can anyone help? code below.

       

      thanks

       

      lister

       

       

      tell application "Adobe InDesign CS6"
         set LayerName to "Background"
         tell document 1
            -- Is this layer is exist ?
            try
               set myLayer to layer LayerName
               -- No? -> create it
            on error
               set myLayer to make layer with properties {name:LayerName}
            end try
         end tell 
         set LayerName to "UCL Logo"
         tell document 1
            -- Is this layer is exist ?
            try
               set myLayer to layer LayerName
               -- No? -> create it
            on error
               set myLayer to make layer with properties {name:LayerName}
            end try
         end tell 
         set LayerName to "Blank SRP"
         tell document 1
            -- Is this layer is exist ?
            try
               set myLayer to layer LayerName
               -- No? -> create it
            on error
               set myLayer to make layer with properties {name:LayerName}
            end try
         end tell 
         set LayerName to "Cutting/Ratio Guide"
         tell document 1
            -- Is this layer is exist ?
            try
               set myLayer to layer LayerName
               -- No? -> create it
            on error
               set myLayer to make layer with properties {name:LayerName}
            end try
         
        delete layer "Layer 1"
      
      
         end tell 
      
      
      end
      
        • 1. Re: script to generate a setup of layers in indesign
          BarlaeDC Adobe Community Professional

          Hi,

           

          I was able to run your script without any problems, although find a new version of your script below which uses a function to avoid any duplicate code, therefore making it easier to spot any errors.

          my createNewLayerWithName("Background")
          my createNewLayerWithName("UCL Logo")
          my createNewLayerWithName("Blank SRP")
          my createNewLayerWithName("Cutting/Ratio Guide")
          
          tell application "Adobe InDesign CS6"
              tell document 1
                  delete layer "Layer 1"
              end tell
          end tell
          
          on createNewLayerWithName(LayerName)
              tell application "Adobe InDesign CS6"
                  tell document 1
                      try
                          set myLayer to layer LayerName
                      on error
                          set myLayer to make layer with properties {name:LayerName}
                      end try
                  end tell
              end tell
          end createNewLayerWithName
          

           

           

          Hope this helps

           

          Malcolm

          • 2. Re: script to generate a setup of layers in indesign
            lister110 Level 1

            Thanks for this, Im not sure what Im doing, but when open the script and try to save this (in script editor) I get a syntax error "". not sure why?

            • 3. Re: script to generate a setup of layers in indesign
              BarlaeDC Adobe Community Professional

              Hi,

               

              Can you post a screen shot of the code and the error?

               

              Regards

               

              Malcolm