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

Add swatch throwing error 1200

Community Beginner ,
Sep 17, 2014 Sep 17, 2014

I have a simple script which is attempting to add a swatch. However, it is throwing "Error 1200: an Illustrator error occurred: 1312914990 ('NA~.') Line: 18 -> newSpot.colorType = ColorModel.SPOT;" This is an example taken straight from the docs, the only change I have made is that I am getting my CMYK values from an object (colors). Also, when I hard-code the values for the CMYK values, it works.

function main(argv) {

  addSwatch('Black');

}

var colors = {"Black": {"c": 0, "m": 0, "y": 0, "k": 100}};

function addSwatch(color) {

  var newSpot = activeDocument.spots.add();

  var newColor = new CMYKColor();

  newColor.cyan = colors[color].c;

  newColor.magenta = colors[color].m;

  newColor.yellow = colors[color].y;

  newColor.black = colors[color].k;

  newSpot.name = color;

  newSpot.colorType = ColorModel.SPOT;

  newSpot.color = newColor;

  var newSpotColor = new SpotColor();

  newSpotColor.spot = newSpot;

}

main();

TOPICS
Scripting
772
Translate
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

Valorous Hero , Sep 17, 2014 Sep 17, 2014

You had it fine, you just can't name it "Black".  addSwatch('black');  will work but not addSwatch('Black');

Translate
Adobe
Valorous Hero ,
Sep 17, 2014 Sep 17, 2014

It was something with the order in which you do this process.

        function addSwatch(color) {

          var newSpot = activeDocument.spots.add();

          newSpot.colorType = ColorModel.SPOT;

          var newColor = new CMYKColor();

          newColor.cyan = colors[color].c;

          newColor.magenta = colors[color].m;

          newColor.yellow = colors[color].y;

          newColor.black = colors[color].k;

          newSpot.color = newColor;

          var newSpotColor = new SpotColor();

          newSpotColor.spot = newSpot;

          newSpotColor.name = color;

        }

I guess after you assign the spot a color model, you can't give it a name, so you give the name to the swatch-spot-color-thing-object which was created with new SpotColor() and had your spot assigned to it.

Scratch that, it's not putting the name on it.

Translate
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 Beginner ,
Sep 17, 2014 Sep 17, 2014

This should probably be reflected in the documentation as well because it is currently how I had it:

Creating a new spot color

// Creates a new spot color in the current document, then applies an 80% tint to the

color

if ( app.documents.length > 0 ){

var doc = app.activeDocument;

// Create the new spot

var newSpot = doc.spots.add();

// Define the new color value

var newColor = new CMYKColor();

newColor.cyan = 35;

newColor.magenta = 0;

newColor.yellow = 50;

newColor.black = 0;

// Define a new SpotColor with an 80% tint

// of the new Spot's color. The spot color can then

// be applied to an art item like any other color.

newSpot.name = "Pea-Green";

newSpot.colorType = ColorModel.SPOT;

newSpot.color = newColor;

var newSpotColor = new SpotColor();

newSpotColor.spot = newSpot;

newSpotColor.tint = 80;

}

Translate
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
Valorous Hero ,
Sep 17, 2014 Sep 17, 2014

Oh DUH!!  Haha you just can't use "Black" as a color name.. reserved.

Translate
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
Valorous Hero ,
Sep 17, 2014 Sep 17, 2014

You had it fine, you just can't name it "Black".  addSwatch('black');  will work but not addSwatch('Black');

Translate
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 Beginner ,
Sep 17, 2014 Sep 17, 2014
LATEST

Good catch! Thanks for your help!

Translate
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