- select all in layer
- create a new swatch group
- get swatches in group
just a thought, not tested.
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?
or if you're using VB, you can use older versions, doScript has always been there
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.
Thanks for your help, Carlos!
I don't like actions either, sometimes it's the only way though.
you're right, can't bypass the dialog either
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!
"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?
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!]).
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.
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.
Well played Vasilly. Well played.
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.
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?