0 Replies Latest reply on Sep 8, 2014 9:18 AM by nellbern

    catch chose from list results, & use it

    nellbern Level 1

      The following script will activate/deactivate layers based on the letter {A, E, D, F} chosen from the list, then export single page (w 3 digits for the page number section) PDF. The problem I have I don't know to trap or cacth the results of whatever is chosen from the list & use it to name the pdf. If file name is ABC01_A_100.indd & the letter chosen from the list is "E" then final pdf should be ABC01_E_100.pdf.  If  the letter chosen from the list is D then final pdf is  ABC_D_100.pdf.  Basically what is changing whatever is between the two underscores _?_

      I can see the results on the events window. How can I capture the results of whatever is chosen from list? I tried return statement but no success at all.

       

      •Then the other question is  if i use choose from list with multiple selection allowed in which I can select more letters: A", "E", "D", "F" how can I output different PDFs with whatever is chosen from the list (with the correct layers activated/deactivated) & file names; ABC01_E_100.pdf, ABC01_F_100.pdf, ABC01_F_100.pdf.  See below. Please any input is greatly appreciated.

       

      --------------------------------

      property myPDFpreset : missing value

      set myPDFpreset to "Screen"


      set versionLayers to {"A", "E", "D", "F"}

      set the_choice to (choose from list versionLayers with prompt "What version do you need?" with multiple selections allowed) as text

      set chosenVersionLayer to item 1 of the_choice

       

      -->Activate versions Layers based in what was chosen
      if the_choice is false then error number -128

      if the_choice is "A" then

         myA()

      else if the_choice is "E" then

         myE()

      else if the_choice is "D" then

         myD()

      else if the_choice is "F" then

         myF()

         end if


      on myA()

         tell application "Adobe InDesign CS4"

             tell active document

                 --Activate Layers
                 set properties of layer "Tive" to {visible:true}

                 set properties of layer "Logo" to {visible:true}

                 set properties of layer "Search" to {visible:true}

                 set properties of layer "Z1" to {visible:true}

                 --Hide Layers
                 set properties of layer "Z2" to {visible:false}

                 set properties of layer "Z3" to {visible:false}

                 set properties of layer "NS" to {visible:false}

                 set properties of layer "MD" to {visible:false}

             end tell

             display alert " A activated"

         end tell

      end myA

       

      on myE()

         tell application "Adobe InDesign CS4"

             --set myDocument to active document
             tell active document

                 --Activate Layers
                 set properties of layer "Tive" to {visible:true}

                 set properties of layer "Logo" to {visible:true}

                 set properties of layer "Search" to {visible:true}

                 set properties of layer "Z2" to {visible:true}

                 --Hide Layers
                 set properties of layer "Z1" to {visible:false}

                 set properties of layer "Z3" to {visible:false}

                 set properties of layer "NS" to {visible:false}

                 set properties of layer "MD" to {visible:false}

             end tell

             display alert " E activated"

              end tell

      end myE

       

      on myD()

         tell application "Adobe InDesign CS4"

             --set myDocument to active document
             tell active document

                 --Activate Layers
                 set properties of layer "Tive" to {visible:true}

                 set properties of layer "Logo" to {visible:true}

                 set properties of layer "Z3" to {visible:true}

                 --Hide Layers
                 set properties of layer "Z1" to {visible:false}

                 set properties of layer "Z2" to {visible:false}

                 set properties of layer "NS" to {visible:false}

                 set properties of layer "MD" to {visible:false}

                 set properties of layer "Search" to {visible:false}

                

             end tell

             display alert "D activated" giving up after 6

              end tell

      end myD

       

      on myF()

         tell application "Adobe InDesign CS4"

             --set myDocument to active document
             tell active document

                 --Activate Layers
                 set properties of layer "Tive" to {visible:true}

                 set properties of layer "Logo" to {visible:true}

                 set properties of layer "Z3" to {visible:true}

                 set properties of layer "NS" to {visible:true}

                 --Hide Layers
                 set properties of layer "Z1" to {visible:false}

                 set properties of layer "Z2" to {visible:false}

                 set properties of layer "MD" to {visible:false}

                 set properties of layer "Search" to {visible:false}

             end tell

             display alert "F activated" giving up after 6

          end tell

      end myF

      ---======================

      tell application "Adobe InDesign CS4"

         activate

         set source_folder to file path of active document --Put the PDFs same folder as ID file

         set theName to name of active document

         set text item delimiters of AppleScript to {"_"}

         set theShortName to text 1 thru text item -2 of theName

         --text 1 thru text item -2 is every character from the first character to the second to last text item
         set text item delimiters of AppleScript to ""

       

        tell application "Finder"

             if (exists folder "PDFs" of folder source_folder) is false then

                 make folder at source_folder with properties {name:"PDFs"}

             end if

         end tell

        

         repeat with x from 1 to count pages of active document --single pages

             set thePageName to name of page x of active document

             set page range of PDF export preferences to thePageName

            

             --section-page number M-U-S-T have 3 digits
             set threeDigitPageName to text -3 thru -1 of ("00" & thePageName)

             (* text 1 thru 3 are the first 3 characters
                         text -3 thru -1 are the last 3 characters*)

             set theFilePath to source_folder & "PDFs:" & theShortName & "_" & threeDigitPageName & ".pdf" as string

       

      ----Export PDF as single pages
             tell active document

                 export format PDF type to theFilePath using myPDFpreset without showing options

             end tell

        

      end repeat

      end tell