12 Replies Latest reply on Dec 14, 2008 5:37 PM by sstanleyau

    [AS] get a list of the used swatch colours in a document

    sstanleyau Level 4
      You're not going to get anything else approaching the simplicity of those<br />two lines. What do you mean by a "50% result"?<br /><br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
        • 1. Re: [AS] get a list of the used swatch colours in a document
          Kevin Parrott Level 2
          I mean im getting half the result that I am looking for,in that the code returns all the colours remaining in the swathes pallete and I am uncertain as to how to achieve as mentioned

          "I am trying to find out how to get a list of the used swatch colours in a document, not including, "None", "Registration", "Paper", and "Black" (black only if it is not used, if used then add to used list)."

          Kev
          • 2. Re: [AS] get a list of the used swatch colours in a document
            sstanleyau Level 4
            You'll have to loop through your list, building a new list that doesn't<br />include those that math the list of ones you want to exclude.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
            • 3. Re: [AS] get a list of the used swatch colours in a document
              Kevin Parrott Level 2
              ok, ive got he below, which works well (can it be improved upon Shane)?

              The problem I have run into now is if I use "Black" in my document it will not show in the list as a used swatch because it is in the _NotUsed list.

              ------------
              tell application "Adobe InDesign CS3"
              activate
              delete unused swatches of document 1
              set _NotUSED to {"None", "Paper", "Black", "Registration"}
              set _UpDatedList to get (name of swatches of document 1 whose name is not in _NotUSED)
              set _NewList to choose from list _UpDatedList with prompt "Choose"
              end tell
              --------

              Kev
              • 4. Re: [AS] get a list of the used swatch colours in a document
                sstanleyau Level 4
                The only way to tell if Black has been used is to check that it hasn't been<br />used as fill or stroke color for any item or text, something that's not<br />particularly simple to do.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                • 5. Re: [AS] get a list of the used swatch colours in a document
                  Kevin Parrott Level 2
                  Hi Shane thanks for pointing me in the right direction, I have come up with the below which does what I am after, how would I go about having the result returned as individual colors, not in a list but like

                  set {a} to color/swatch 1 of the result
                  set {b} to color/swatch 2 of the result

                  not quite sure how to go about it

                  ----------------
                  tell application "Adobe InDesign CS3"
                  activate
                  delete unused swatches of document 1
                  set _NotUSED to {"None", "Paper", "Black", "Registration", "Keyline"}
                  set _UpDatedList to get (name of swatches of document 1 whose name is not in _NotUSED)
                  set _myDoc to active document
                  tell _myDoc
                  set _Colour1 to swatch "Black"
                  set _FillColour to every page item of _myDoc whose fill color is _Colour1
                  set NumberOfColoredObject to count of _FillColour
                  set _StrokeColour to every page item of _myDoc whose stroke color is _Colour1
                  set _Stroke_Fill to _FillColour & _StrokeColour
                  if (count of _Stroke_Fill) = 0 then
                  set _NewList to _UpDatedList
                  else if (count of _Stroke_Fill) > 0 then
                  set _NewList to _UpDatedList & "Black"
                  end if
                  end tell
                  end tell

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

                  Budgie
                  • 6. Re: [AS] get a list of the used swatch colours in a document
                    sstanleyau Level 4
                    On 12/12/08 7:27 AM, "KEVINP1" <member@adobeforums.com> wrote:<br /><br />> ow would I go about having the result returned as individual colors<br /><br />Can you elaborate? I'm not sure what you mean.<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                    • 7. Re: [AS] get a list of the used swatch colours in a document
                      Eric @ MCA Level 3
                      Do you mean the actual CMYK values of each color? If so, something like this would work, but it would be mightily redundant if you have ID naming colors by their CMYK values, lol...
                      tell application "Adobe InDesign CS3"
                      
                      tell active document
                        set colorList to ""
                        set myColors to name of every color
                        repeat with thisColor in myColors
                         set colorList to colorList & thisColor & " -- C: " & item 1 of color value of color thisColor
                         set colorList to colorList & ", M: " & item 2 of color value of color thisColor
                         set colorList to colorList & ", Y: " & item 3 of color value of color thisColor
                         set colorList to colorList & ", K: " & item 4 of color value of color thisColor & return
                        end repeat

                        display dialog colorList
                      end tell
                      end tell
                      • 8. Re: [AS] get a list of the used swatch colours in a document
                        Kevin Parrott Level 2
                        Eric: Thanks for the reply, but no that is not what I meant, probably didn't explain my self that well, sorry.

                        Shane: In script editor in the result window when I run my script I get this

                        {"PANTONE 430 C", "PANTONE Warm Red U", "PANTONE Process Cyan CVC", "Black"}

                        what I want to do is have that result displayed/returned something like this:

                        Colours used in this document are: PANTONE 430 C & PANTONE Warm Red U & PANTONE Process Cyan CVC & Black

                        But using the below code:

                        set _NewList to _UpDatedList & "Black"
                        set _Result to "Colours used in this document are: " & _NewList

                        I get this:

                        "Colours used in this document are: PANTONE 430 CPANTONE Warm Red UPANTONE Process Cyan CVCBlack"

                        how would I go about getting what I am after, hope this explains things better

                        Kev
                        • 9. Re: [AS] get a list of the used swatch colours in a document
                          sstanleyau Level 4
                          You need to use AppleScript's text item delimiters (and reset them when you<br />finish). Something like this:<br /><br /><br />set _NewList to _UpDatedList & "Black"<br />set oldDelims to AppleScript's text item delimiters<br />set AppleScript's text item delimiters to {" & "}<br />set _Result to "Colours used in this document are:  " & _NewList<br />set AppleScript's text item delimiters to oldDelims<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>
                          • 10. Re: [AS] get a list of the used swatch colours in a document
                            Kevin Parrott Level 2
                            cheers shane

                            hmmmm, just found something interesting, my script does of it what I ask apart from when their is black text only in my document (which is a fill, right?), the script does not recognize the fill of the text, yet if the text is say cyan or magenta it will see these colours, but not the black, any thoughts on this?

                            I am starting to see what you mean by "something that's not particularly simple to do." Sahne :)

                            Kev
                            • 11. Re: [AS] get a list of the used swatch colours in a document
                              Kevin Parrott Level 2
                              cheers shane

                              hmmmm, just found something interesting, my script does of it what I ask apart from when their is black text only in my document (which is a fill, right?), the script does not recognize the fill of the text, yet if the text is say cyan or magenta it will see these colours, but not the black, any thoughts on this?

                              I am starting to see what you mean by "something that's not particularly simple to do." Shane :)

                              Kev
                              • 12. Re: [AS] get a list of the used swatch colours in a document
                                sstanleyau Level 4
                                You need to search for text that uses the color, as well as page items, drop<br />shadows, tables, graphics...<br /><br />-- <br />Shane Stanley <sstanley@myriad-com.com.au><br />AppleScript Pro Florida, April 2009 <a href=http://scriptingmatters.com/aspro>