Skip to main content
Participant
January 26, 2008
Question

Swatch name Variable

  • January 26, 2008
  • 2 replies
  • 486 views
Hi,

It's my first time posting on this forum. I´m new around scripting but I need to do a simple task. I think It´s impossible without using script.

Example: I have 4 rectangles, each one with personalized colors using color Palette. Model is RGB.

I created an action which automaticaly selects each object and save its color in Swatchs panel.

I´m able to reach the result which automaticaly selects object per object and saves its color.

But, the problem is that I´d like Illustrator to save the color name as Color 1, Color 2 (a name plus a variable), instead of saving name as color composition (R-255 B-10 G-30). Its impossible to record swatch name desired in the action.

Is there any way to create a script which select one object a time, save its color in the swatch palette with the name color 1 and do that for all objects in the artboard. So, a sequence name of color 1, color 2, as Photoshop would do if you create color swatches?

How to create

Thank you for any advice
This topic has been closed for replies.

2 replies

Known Participant
June 16, 2008
Something like the following should work (untested)

Set your count var

var colorCount = 0;

After you set the swatch :

var lastSwatchIndex = app.activeDocument.swatches.length-1;
var lastSwatch = app.activeDocument.swatches[lastSwatchIndex];
lastSwatch.name = "Color "+colorCount;

iterate the counter
Participant
June 11, 2008
SDFasdfASD