5 Replies Latest reply on Nov 29, 2016 1:44 AM by Laubender

    Make Color Label Script?

    ciaronf87991928

      Hi, I am trying to use a script that will add a text box underneath the swatch box in a document. I found an applescript that does this, but it also adds the LAB value and I only need the pantone value. Can anyone help with this?  Screenshot below shows what I am getting

      Screen Shot 2016-11-28 at 12.03.50 PM.png

       

       

      I've also attached the applescript

       

      Screen Shot 2016-11-28 at 12.33.55 PM.png

        • 1. Re: Make Color Label Script?
          [Jongware] Most Valuable Participant

          Is that an image of your code?

           

          Out of curiosity: if we make the requested changes to it (with Photoshop I presume) and upload it again, just how are you going to run it?

          • 2. Re: Make Color Label Script?
            ciaronf87991928 Level 1

            Hi it wouldn't let me upload the applescript file onto the adobe forum here, i'm not sure how to send it?

            • 3. Re: Make Color Label Script?
              [Jongware] Most Valuable Participant

              Copy and paste does not work?

              • 4. Re: Make Color Label Script?
                ciaronf87991928 Level 1

                Oh sorry ha!

                 

                tell application "Adobe InDesign CC 2017"

                  set myDocument to active document

                  --set units

                  set horizontal measurement units of view preferences of myDocument to points

                  set vertical measurement units of view preferences of myDocument to points

                 

                  --make a layer and style sheet for the document if it doesn't exist

                  tell myDocument

                  try

                  make new paragraph style with properties {name:"Labels", applied font:"Lucida Grande", point size:5, left indent:0}

                  set myLabelStyle to paragraph style "Labels"

                  on error

                  set myLabelStyle to paragraph style "Labels"

                  end try

                  end tell

                 

                  --get all the page items

                  set myItems to selection

                 

                  --get the fill color and make a label at bottom

                  repeat with x from 1 to count of myItems

                  set myFill to fill color of item x of myItems

                  try

                  --if space of myFill is CMYK then

                  my MakeLabel(myFill, item x of myItems, myLabelStyle)

                  --end if

                  end try

                  end repeat

                end tell

                 

                --make labels (the cmyk color, the object, the label style)

                on MakeLabel(myColor, myRectangle, myLabelStyle)

                  tell application "Adobe InDesign CC 2017"

                  set cv to color value of myColor as list

                  set n to "— "

                  repeat with a in cv

                  set a to round a rounding up

                  set n to n & a & "|"

                  end repeat

                  --get the label text

                  set x to (count of characters of n) - 1

                  set n to characters 1 thru x of n

                  set myLabelString to name of myColor & " " & space of myColor & " " & n

                 

                  set AppleScript's text item delimiters to "LAB"

                  set myLabelString to text item 1 of myLabelString

                 

                 

                  -- make the label box below the page item [y1, x1, y2, x2]

                  set {a, b, c, d} to geometric bounds of myRectangle

                  tell parent of myRectangle

                  set myTextFrame to make text frame with properties {geometric bounds:{c, b, c + 25, d}, contents:myLabelString}

                  tell myTextFrame

                  set first baseline offset of text frame preferences to leading offset

                  set applied paragraph style of text 1 to myLabelStyle

                  end tell

                  end tell

                  end tell

                end MakeLabel

                • 5. Re: Make Color Label Script?
                  Laubender Adobe Community Professional & MVP

                  Hi ciaron,

                  the simple solution would be to remove the line with lab values after running the script with a GREP Find/Replace action.

                  Will that "TCX LAB" substring always be there if a LAB value is emitted? And is the end of the line after the PANTONE entry always a paragraph sign or a forced line break?

                   

                  If yes, you could do something like that:

                   

                  Find GREP pattern

                  \s^TCX LAB.+$
                  

                   

                  Replace

                  with nothing

                   

                  And you could restrict your search to the applied paragraph style of your label.

                   

                  Regards,
                  Uwe