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

What is the FASTEST way to identify colors used on a layer?

Engaged ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

Hi All,

Is there any "faster" way to identify colors used on a given layer other than to iterate through the layer's pageitems?  I am optimizing a few scripts and am looking to squeeze milliseconds as a layer with a lot of pageitems can take a while (relatively speaking of course). 🙂  Any perspectives would be appreciated.

All the best!!

-TT

TOPICS
Scripting

Views

891

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
Adobe
Community Expert ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

Hi TT

- select all in layer

- create a new swatch group

- get swatches in group

just a thought, not tested.

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
Engaged ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

Hey Carlos,

I haven’t been able to figure out how to create a new swatch group using selected items (of the document) without using the UI. Am I missing something?

Thanks,

-TT

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 ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

are you on CS6 or newer? record an action to create a new swatch group, then play such action with javascript using app.doScript('actionName', 'setName')

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 ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

or if you're using VB, you can use older versions, doScript has always been there

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
Engaged ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

Hi Carlos,

I try to stay away from Action calls when possible - I'd even prefer an "app.ExecuteMenuCommand" just because they are more stable (just wish there was more documentation on commands). However, in the absence of any other solution, I tried your suggestion and still wind up with a "New Color Group" modal dialog from AI which locks up the script until it is answered/accepted in AI, even with the third parameter set to FALSE, as in:

app.DoScript("CreateNewColorGroup", "TestSwatches", False)

I suppose it's possible for me to launch a threaded scavenger to hunt down the top dialog window and perform a SendKeys() to it, but again I dislike doing that (beside it taking a lot of work! 😞 ) because I prefer staying within API's and not just blindly sending keystrokes or cutting/pasting.

I think that your idea would work very well, but I just can't get past the UI dialog.

Any thoughts?

Thanks for your help, Carlos!

-TT

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 ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

I don't like actions either, sometimes it's the only way though.

you're right, can't bypass the dialog either

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
Engaged ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

Well, aside from having to deal with the dialog, the time savings is still very substantial. The only real problem is that the dialog box has to be squelched for every layer. 😞   But your idea was, as always, BRILLIANT!

Thanks, Carlos!

-TT

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 ,
Jan 17, 2015 Jan 17, 2015

Copy link to clipboard

Copied

"Add Selected Colors" brings no dialog, swatches get added at the end, so you could count the existing swatches, before and after running the action...but, always a but, if a swatch already exist, it doesn't get added again...so, plan D, copy selection, create a new document with no swatches, paste selection, run action, get swatches...

...how's that for a "faster" method?

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
Engaged ,
Jan 18, 2015 Jan 18, 2015

Copy link to clipboard

Copied

Oh, yeah. Haha. THAT ought to do it!

One thing that came out of this that I think bears mentioning (at least for VB) is that Layer.HasSelectedArtwork = False is listed as deselecting all selected art which is true. However, the opposite is also true, where Layer.HasSelectedArtwork = True will select all art on that layer, not exactly what the property describes nor what the VB documentation states (big surprise, eh?). Now I know that you, Carlos, probably already know this, being the AI Obi-Wan Kenobi, (just messin' man) but I thought that maybe somebody else may benefit from this.

Thanks again, Carlos, for your help. I'll leave this open for a while to mark the correct answer in case somebody else has another approach (without dialogs [haha!]).

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 ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

ThinkingThings I actually just built a script to do this very task. For my purposes, i was duplicating the page items onto a new layer.. but you don't need to.

The you can use the document's inkList. If you're seeking a specific layer, you can simply set the property 'printable' to false for all other layers. then redraw() and then return the inkList colors whose printStatus == PrintingStatus.ENABLEINK. (only the target layer's colors will be displayed since any colors from a (printable = false) layer will be disabled in the inkList.

if you need to return the colors from each layer, you can just throw the whole function into a for loop to cycle through the layers.

Sorry, i know that was a really brief description, but it works great and is VERY fast. Let me know if you have any questions.

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
Valorous Hero ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

William, your script only works for ink plates, which is fine if your only concern is spot colors, or ink plates, but his may be a different use where he wants to gather actual color process numbers or non-spot 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
Community Expert ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

Well played Vasilly. Well played.

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
Engaged ,
Jan 27, 2015 Jan 27, 2015

Copy link to clipboard

Copied

Hey Guys,

Thanks for keeping this thread in mind -- I have managed to get this to work with just ONE manual intervention (ENTER key) so far (down from 1 x # colors), but I think/hope that with some additional work I can nail it entirely. I've been jammed up on another InDesign issue so when I can I'll try to get back with an update.

-TT

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
Engaged ,
Jan 30, 2015 Jan 30, 2015

Copy link to clipboard

Copied

LATEST

In this continuing quest, I find that deleting a swatch color group in a group via the UI behaves differently than in code, e.g.:

aDoc.SwatchGroups("Color Group 1").Delete()

With the UI, the SwatchGroup and contained swatches are deleted (in this case spot colors), but the spot colors are retained in the document's swatches (a preferred result). However, in code, when the SwatchGroup is deleted, much to my surprise, all the document's spot color swatches are converted to RGB colors (in this case that's the prevailing color mode) from Spot Colors.

Am I missing something?

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