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

Spot color not found

Contributor ,
Oct 06, 2024 Oct 06, 2024

Copy link to clipboard

Copied

Could you detect a problem here? The document swatches pallete contains spot color named PANTONE 1945 C, newetherless I get the error here. Spots listing prints the same name as in the spotName. What did I miss?

 

 

alert(spotName); //PANTONE 1945 C
try {
    doc.spots.getByName(spotName);
} catch (e) {
    alert('Spot not found');
    $.writeln("---------");
    var spots = doc.spots;
    for (var i = 0; i < spots.length; i++) {
        $.writeln(spots[i].name); //PANTONE 1945 C
    }
    $.writeln("---------");
    return;
}

 

 

The above situation occurs when a color has been added from the pantone library to the swatch palette. If I create a spot color through "New Swatch" with the name "PANTONE 1945 C" then the error will go away, any thoughts?

 

p.s. What is the reason that the code highlighting is present in the edit window, but is not shown when published in this post?

TOPICS
Scripting

Views

214

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 , Oct 06, 2024 Oct 06, 2024

Hi @Charu Rajput as it turned out the spotName value didn't come in UTF-8 encoding.

Votes

Translate

Translate
Adobe
Community Expert ,
Oct 06, 2024 Oct 06, 2024

Copy link to clipboard

Copied

Hi

@fastwind - Not sure if you have declared all variables in your script, please try below version if that works and if works, try to integrate in your workflow

 

var spotName = "PANTONE 1945 C";
alert(spotName);

var doc = app.activeDocument;
var spots = doc.spots;
try {
    doc.spots.getByName(spotName);
    for (var i = 0; i < spots.length; i++) {
        alert(spots[i].name);
    }
} catch (e) {
    alert('Spot not found');
}
Best regards

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 ,
Oct 06, 2024 Oct 06, 2024

Copy link to clipboard

Copied

Hi @Charu Rajput as it turned out the spotName value didn't come in UTF-8 encoding.

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
Community Expert ,
Oct 07, 2024 Oct 07, 2024

Copy link to clipboard

Copied

@fastwind - Could you please posta. screenshot what excatly you are getting after running the above script?

Best regards

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 ,
Oct 07, 2024 Oct 07, 2024

Copy link to clipboard

Copied

LATEST

@Charu Rajput already fixed...

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