Copy link to clipboard
Copied
Am I correct that one can only get a pathItems fill swatch by making sure that only that pathItem is selected, color the stroke color the same as the fill color and use doc.swatches.getSelected() ?
Yuck, vomit.
The only other method that would be less reliable is to compare the color properties to the properties of the swatches. If they don't match then it's not the match and if they do then it could be or it could be another swatch with the same color properties.
Am I (I hope I am not) correct or is there a normal way of doing this?
unfortunately you're correct
the normal is there's no normal. I would probably go the other way around and loop through my swatches and select whatever has that swatch applied, do my thing, deselect, repeat. Would that approach help you?
Copy link to clipboard
Copied
unfortunately you're correct
the normal is there's no normal. I would probably go the other way around and loop through my swatches and select whatever has that swatch applied, do my thing, deselect, repeat. Would that approach help you?
Copy link to clipboard
Copied
Thanks for the confirmation. Coming from an InDesign background I find these basic lackings in the API somewhat mindbogglingly, all I can say is that I am grateful that I basically don't take on PS jobs!
The approach you wrote could well be useful.
How can I select all items of a particular swatch with scripting?
Copy link to clipboard
Copied
Trevor×… wrote
all I can say is that I am grateful that I basically don't take on PS jobs!
you mean AI jobs?
I get you, I used to be jealous of the ID/PS apis and I don't even script on those programs...but after lots of meditation hours I'm at peace with our api now.
here you go, as usual idoc is my doc reference and swatch is my swatch reference.
// assign color to default color
idoc.defaultFillColor = swatch.color;
// find same fill color...aka select all items matching default fill color
app.executeMenuCommand("Find Fill Color menu item");
// in case you need this too.
idoc.defaultFillColor = new NoColor;
Copy link to clipboard
Copied
Thanks.
I actually did mean PS.
Although I did start on InDesign and have a much better knowledge of the ID API about 90% of my Jobs are Ai.
I do a lot of non-API stuff.
Copy link to clipboard
Copied
cool!!
I do 100% ai
Copy link to clipboard
Copied
That's why I'm asking and you're answering
Find more inspiration, events, and resources on the new Adobe Community
Explore Now