Copy link to clipboard
Copied
I need to implement a script like 'recolor artwork' wizard in AI.
And I already wrote a script that loop change pathItems color one by one. It's work for few pathItems. But does not work for my job that contains more than 100,000 pathItems. You know that's too slow.
So, I need help. How can I set color to group of all pathItems in a time ? or do we have a better way to do ?
Best regards
Copy link to clipboard
Copied
Moving to Illustrator Scripting​
Copy link to clipboard
Copied
set the document's defaultFillColor to your desired color and then use an app.executeMenuCommand("Find Fill Color menu item") to select all shapes of one color, or use one of the available selection commands that does not rely on looping such as layer.hasSelectedArtwork = true, to get your shapes selected and then set the document's defaultFillColor to change all in one instance without resorting to a loop.
Copy link to clipboard
Copied
Cool. It's work with just 3 lines of code
// choose the source color that will be changed
doc.DefaultFillColor = srcColor;
// select all object that has the color same source color
app.ExecuteMenuCommand("Find Fill Color menu item");
// change the color of selected object to dst color
doc.DefaultFillColor = dstColor;
Thank you.