• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Applescript to list swatches in swatch panel in a text box

Explorer ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

How do I get Applescript to read all swatches used in the swatch panel, and list them in a text box?

 

I actually just need the part that tells it to read the swatch colors in the swatches panel list

TOPICS
How to , Scripting

Views

664

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 2 Correct answers

Advisor , Jul 26, 2022 Jul 26, 2022

Hello @denisep726548,

 

Give this a try and see if it works for you...

 

_ _

 

tell application id "com.adobe.indesign"
tell active document
delete unused swatches
set allSwatches to every swatch

set SwatchList to ""

set mySwatches to get (name of swatches)

try
set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
on error
set noprint to every color whose name is "noprint"
end try
try
wb to make color with properties {model:spot, space:CMYK, color value:{0,

...

Votes

Translate

Translate
Community Expert , Jul 26, 2022 Jul 26, 2022

it was only searching page items and then not listing spot colors that were used in the placed eps files.

 

There’s no way to check an EPS’s spot colors from within InDesign, so if you want to include spot colors that are brought in via a placed asset, there’s no point in looping thru the page items and text. The only choice would be to simply output the used swatch list—the code without the page item and text loop:

 

tell application id "com.adobe.indesign"
	tell active document
		delete unused
...

Votes

Translate

Translate
Adobe Employee ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

Hi @denisep726548 ,

 

Thanks for reaching out. I am not a scripting expert however I found a similar discussion on the community which you can refer to here https://community.adobe.com/t5/indesign-discussions/as-get-a-list-of-the-used-swatch-colours-in-a-do...

 

If that's not what you were looking for, I am leaving this discussion open for expert suggestions.

 

Regards
Rishabh

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 22, 2022 Jul 22, 2022

Copy link to clipboard

Copied

Hello @denisep726548,

 

Give this a try...

 

--

tell application "Adobe InDesign 2022"

tell active document

set SwatchList to ""

set mySwatches to get (name of swatches)

repeat with thisSwatch in mySwatches

set SwatchList to SwatchList & thisSwatch & return

end repeat

display dialog SwatchList

end tell


end tell

--

 

Regards,

Mike

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Can you help me incorporate that in to the attached sample script?

I get an error that name is not recognized.

Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Hello @denisep726548,

 

what is your expected output for the "Used Swatches:" list? All the swatches in the document??

 

Regards,

Mike

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Yes. That will work. I will delete unused first, and list all swatches in the document, with the exception of some like "paper" or "registration"

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advisor ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Hello @denisep726548,

 

Give this a try and see if it works for you...

 

_ _

 

tell application id "com.adobe.indesign"
tell active document
delete unused swatches
set allSwatches to every swatch

set SwatchList to ""

set mySwatches to get (name of swatches)

try
set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
on error
set noprint to every color whose name is "noprint"
end try
try
wb to make color with properties {model:spot, space:CMYK, color value:{0, 0, 0, 100}, name:"wb"}
on error
set wb to every color whose name is "wb"
end try
try
set infoLayer to make layer with properties {name:"Job Info - Non-Print", printable:true, layer color:blue}
on error
set infoLayer to every layer whose name is "Job Info - Non-Print"
end try
--delete all page items of infoLayer

tell spread 1
delete every page item of item 1 of infoLayer

---------gets the spread’s used swatches---------

repeat with thisSwatch in mySwatches

set SwatchList to SwatchList & thisSwatch & return

end repeat

--the spread’s page items
set api to all page items
--an array to check used swatches, these are skipped
set sl to {"None", "Registration", "Paper", "Black"}
--a string for the used names
set ul to "Used Swatches:" & return & SwatchList


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

set slugText to make new text frame with properties {geometric bounds:{(item 4 of page 1's bounds), 0.25, ((item 3 of page 1's bounds) + -1), 3}, stroke color:"noprint", stroke weight:1, item layer:"Job Info - Non-Print"}
--se the contents to the list
set contents of slugText to ul
set fill color of text 1 of slugText to "noprint"
set applied font of text 1 of slugText to "Adobe Caslon Pro"
set font style of text 1 of slugText to "Semibold Italic"
set first line indent of text 1 of slugText to 0.125
end tell
end tell
end tell

_ _

 

Regards,

Mike

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

No. It is not. I did not really get exactly what I wanted. 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

This worked. Thank you. The end result you gave me was a little different than that other post and that is what I needed. Thanks so much.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Sorry, I thought you did not want to list [Paper], [None], Registration

 

Mike’s version gives me this—all of the defaults plus G which does not print:

 

Screen Shot 14.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

you are correct. I dont. The problem I had with the other post is that it was only searching page items and then not listing spot colors that were used in the placed eps files.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

it was only searching page items and then not listing spot colors that were used in the placed eps files.

 

There’s no way to check an EPS’s spot colors from within InDesign, so if you want to include spot colors that are brought in via a placed asset, there’s no point in looping thru the page items and text. The only choice would be to simply output the used swatch list—the code without the page item and text loop:

 

tell application id "com.adobe.indesign"
	tell active document
		delete unused swatches
		set allSwatches to every swatch
		try
			set noprint to make color with properties {model:spot, space:CMYK, color value:{100, 0, 0, 0}, name:"noprint"}
		on error
			set noprint to every color whose name is "noprint"
		end try
		try
			wb to make color with properties {model:spot, space:CMYK, color value:{0, 0, 0, 100}, name:"wb"}
		on error
			set wb to every color whose name is "wb"
		end try
		try
			set infoLayer to make layer with properties {name:"Job Info - Non-Print", printable:true, layer color:blue}
		on error
			set infoLayer to every layer whose name is "Job Info - Non-Print"
		end try

		set ul to "Used Swatches:" & return
		set ds to {"None", "Registration", "Paper", "Black"}
		delete every page item of item 1 of infoLayer
		repeat with x in allSwatches
			if name of x is not in ds then
				set ul to ul & name of x & return
			end if
		end repeat
		
		set slugText to make new text frame with properties {geometric bounds:{(item 4 of page 1's bounds), 0.25, ((item 3 of page 1's bounds) + -1), 3}, stroke color:"noprint", stroke weight:1, item layer:"Job Info - Non-Print"}
		set contents of slugText to ul
		set fill color of text 1 of slugText to "noprint"
	end tell
end tell

 

But as I mentioned in the other post just because a swatch is used doesn’t mean it will print. Here PANTONE Stron Red C is in a placed EPS, but G, Gray20, Gray60 are listed but they will not print:

 

Screen Shot 16.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

There we go! Thank you both for your help.....

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Hey Mike, THe only part that does not seem to work is it still lists the colors I dont want listed under sl

Can you fix that part? Thank you.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

THe only part that does not seem to work is it still lists the colors I dont want listed under sl

 

Right, so the code in the other post returns this:

 

Screen Shot 15.png

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Do you know how I would be able to run this so it applies to any page in the document? or can run it on the current page I am viewing?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

LATEST

That’s the problem you will run into, the latest script is simply listing the document’s used swatches. You want the slug text to list the colors that will print on a given page, but there’s no way of knowing what colors will print–a color could be used on the pasteboard, on another page, behind an object, set to a tint of 0% etc.

 

Also, if you are delivering a PDF, the only named swatches that Export over to the PDF are Spots—named process colors export as CMYK, Lab, or RGB value objects—Acrobat does not know the ID swatch names.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 26, 2022 Jul 26, 2022

Copy link to clipboard

Copied

Rather than a display dialog, I need it to write to the slugtext text box

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines