Copy link to clipboard
Copied
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
I've also attached the applescript
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
Hi it wouldn't let me upload the applescript file onto the adobe forum here, i'm not sure how to send it?
Copy link to clipboard
Copied
Copy and paste does not work?
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
Thanks for the post. Have you had success with this on InDesign 2021?
Copy link to clipboard
Copied
It should work—the script expects a selected rectangle. If you change the application tells to id "com.adobe.indesign" it should work with any version. Also, the original question was how to remove the color values from the label—this would do that:
tell application id "com.adobe.indesign"
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
my MakeLabel(myFill, item x of myItems, myLabelStyle)
end try
end repeat
end tell
--make labels (the cmyk color, the object, the label style)
on MakeLabel(myColor, myRectangle, myLabelStyle)
tell application id "com.adobe.indesign"
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
--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