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

How to get swatch with specific name by using Script?

Participant ,
Sep 16, 2010 Sep 16, 2010

Copy link to clipboard

Copied

Hi Guys,

I need small help. Looking for Java/action script which create swatch with specific name by single click. I tried to create by using action sctipt, but it is not creating with specific name. So i am requesting you to provide me the script for this. Really it will help lot for me.

Thanks in advance.

Regards

HARI

TOPICS
Scripting

Views

885

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

Guide , Sep 16, 2010 Sep 16, 2010

This assumes you have an active document and that it is CMYK…

#target illustrator var docRef = app.activeDocument; var newCMYK = new CMYKColor(); newCMYK.cyan = 0; newCMYK.magenta = 0; newCMYK.yellow = 0; newCMYK.black = 100; var thisSpot = docRef.spots.add(); thisSpot.name = 'Stans'; thisSpot.color = newCMYK; thisSpot.colorType = ColorModel.SPOT;

Votes

Translate

Translate
Adobe
Guide ,
Sep 16, 2010 Sep 16, 2010

Copy link to clipboard

Copied

Swatches are a general collection of objects. They can contain colors, gradients, patterns, spots etc. What are you trying to add? Here is one way of adding some colors to the swatches pallet. Note you should test the documents color space for either RGB or CMYK before applying your choice.

#target illustrator var docRef = app.activeDocument; with (docRef) {      var a = cmykColor(0, 100, 100, 10);      makeSwatch(docRef, 'Testing CMYK', a);      //var b = rgbColor(255, 0, 155);      //makeSwatch(docRef, 'Testing RGB', b);      var c = grayColor(45);      makeSwatch(docRef, 'Testing Gray', c) } function cmykColor(c, m, y, k) {      var newCMYK = new CMYKColor();      newCMYK.cyan = c;      newCMYK.magenta = m;      newCMYK.yellow = y;      newCMYK.black = k;      return newCMYK; } function rgbColor(r, g, b) {      var newRGB = new RGBColor();      newRGB.red = r;      newRGB.green = g;      newRGB.blue = b;      return newRGB; } function grayColor(g) {      var grayColor = new GrayColor();      grayColor.gray = g;      return grayColor; } function makeSwatch(doc, swName, swCol) {      if (!inCollection(doc.swatches, swName)) {           var thisSwatch = doc.swatches.add();           thisSwatch.name = swName;           thisSwatch.color = swCol;           return thisSwatch;      }else{           return doc.swatches.getByName(swName);      } } function inCollection(collection, nameString) {      var exists = false;      for (var i = 0; i < collection.length; i++) {           if (collection.name == nameString) {                exists = true;           }      }      return exists; }

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
Participant ,
Sep 16, 2010 Sep 16, 2010

Copy link to clipboard

Copied

Hi Muppet Mark

Thanks for reply, but i am not good in scripting. I'll tell you that how I am expecting.

I want swatch with following properties

Name               :     Stans

Colour              :     100% Black

Colour Type     :     Spot Color

If you help me for this it would be really helpful for me.

Thanks in advance...

Regards

HARI

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
Guide ,
Sep 16, 2010 Sep 16, 2010

Copy link to clipboard

Copied

This assumes you have an active document and that it is CMYK…

#target illustrator var docRef = app.activeDocument; var newCMYK = new CMYKColor(); newCMYK.cyan = 0; newCMYK.magenta = 0; newCMYK.yellow = 0; newCMYK.black = 100; var thisSpot = docRef.spots.add(); thisSpot.name = 'Stans'; thisSpot.color = newCMYK; thisSpot.colorType = ColorModel.SPOT;

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
Participant ,
Sep 16, 2010 Sep 16, 2010

Copy link to clipboard

Copied

LATEST

woovvv

thanks a lot Muppet Mark

Regards

HARI

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