Copy link to clipboard
Copied
Hi,
I want to remove a certain object with a specific spot color from my document. Is it possible to select it by script?
Select by Spot Color? Convert certain spot color to CMYK Color?
Thanks!
Christoph
Copy link to clipboard
Copied
So there are a couple of ways to do this, but none of them are very pretty.
You can use a simple action to select all of a particular spot color and then remove them. (this probably isn't what you want because it sounds like there's one specific object you're trying to remove. an action will simply remove everything of that same color and you won't have any further control).
You can use a script that loops through every item of the document and checks for certain properties, then if you find the condition you're looking for you can delete the item and you're done. (this is generally a very poor way to go about doing this because it's wildly inefficient and it can run very slow even with relatively few items in your document).
Perhaps the best solution is a combination of these two. You can use a script that calls an action that selects all of a particular spot color and then loops through the selection to find the desired object. This way you don't have to automatically delete all objects of a certain spot color, but you don't have to loop through tons of unnecessary items.
Copy link to clipboard
Copied
Are you asking two separate questions?
It seems that to remove would be easy- you select a color you need by setting the document's "current fill-color square" to your needed color, then using some executeMenuCommands to select same & clear:
#target illustrator
function test(){
var doc = app.activeDocument;
doc.defaultFillColor = doc.swatches["CMYK Yellow"].color;
app.executeMenuCommand("Find Fill Color menu item");
app.executeMenuCommand("clear");
};
test();
To convert to CMYK, you can select the items you need and then use an app.doScript command to play an action you have which recorded the "Convert to CMYK" menu item. Here is an example for a snippet which does this, and will only work if you have such an action in place already.
#target illustrator
function test(){
var doc = app.activeDocument;
doc.defaultFillColor = doc.swatches["Spot!"].color;
app.executeMenuCommand("Find Fill Color menu item");
app.doScript("Action 2", "Test");
};
test();
Copy link to clipboard
Copied
Thank u! This helped a lot!