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

Select Spot color using given CMYK values

Participant ,
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

68

Likes

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

Participant , 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
...

Likes

Translate

Translate
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.

Likes

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
Participant ,
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!

Likes

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
Participant ,
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;
    }
}

Likes

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