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

Select Spot color using given CMYK values

Contributor ,
Nov 04, 2022 Nov 04, 2022

Copy link to clipboard

Copied

Hi community good afternoon, can anybody help me with this? I have the following code:

 

var doc = app.activeDocument;
function SelectSpecificColor () {
doc.selection = null;
var cmykCol = new SpotColor();
cmykCol.cyan=2;
cmykCol.magenta=100;
cmykCol.yellow=2;
cmykCol.black=2;
doc.defaultFillColor = cmykCol;
app.executeMenuCommand("Find Fill Color menu item");
app.redraw();
//alert(doc.selection.length)
// }
}
SelectSpecificColor();

 

which looks for a CMYK value to select all objects/items in the document with that values, BUT when I turn that object into spot color it is not selecting it anymore, maybe cause it changed to spot, but still that new spot color keeps the values of CMYK, is there any way to select that new created spot color with given CMYK values in the code? Thank you

 

AntonioPachecoHN_0-1667587035348.png

 

AntonioPachecoHN_1-1667587078437.png

 

TOPICS
Draw and design , Scripting , SDK , Tools

Views

189

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

correct answers 1 Correct answer

Contributor , Nov 04, 2022 Nov 04, 2022

I found a way to do it, I will look for a swatch name that contains a "key word" then I will select that color as teh default fill color to select, here is the code, thank you all!

 

var doc = app.activeDocument;
var name =  "";
var searchName = "";
for(i=0 ; i<doc.swatches.length; i++){
    name = doc.swatches[i].name;
    searchName = nombre.match("Black");
    if(SearchName == "Black"){
        alert("found at index " + i);
        alert(searchName);
        app.activeDocument.defaultFillColor = doc.swa
...

Votes

Translate

Translate
Adobe
LEGEND ,
Nov 04, 2022 Nov 04, 2022

Copy link to clipboard

Copied

According to the documentation SpotColor — Illustrator Scripting Guide 0.0.1 documentation (docsforadobe.dev) the SpotColor class has properties: spot and tint. If you set other made up properties like cyan or magenta it won't do anything at all.

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
Contributor ,
Nov 04, 2022 Nov 04, 2022

Copy link to clipboard

Copied

Does it mean it is not possible to select a spot color? That's too bad 😕 Can anybody help me with a different code maybe to select that spot color? thanks!

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
Contributor ,
Nov 04, 2022 Nov 04, 2022

Copy link to clipboard

Copied

LATEST

I found a way to do it, I will look for a swatch name that contains a "key word" then I will select that color as teh default fill color to select, here is the code, thank you all!

 

var doc = app.activeDocument;
var name =  "";
var searchName = "";
for(i=0 ; i<doc.swatches.length; i++){
    name = doc.swatches[i].name;
    searchName = nombre.match("Black");
    if(SearchName == "Black"){
        alert("found at index " + i);
        alert(searchName);
        app.activeDocument.defaultFillColor = doc.swatches[i].color;
        app.executeMenuCommand("Find Fill Color menu item");
        i=30;
    }
}

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