Skip to main content
Known Participant
November 17, 2015
Answered

Open a swatch library from a script or adding default swatches to different AI files

  • November 17, 2015
  • 3 replies
  • 2019 views

Ok. This is my issue.

At my work we create different styles of clothing. All those styles come from different AI templates that we customize to meet the clients requirements. Each of these styles needs to be done with an specific set of swatches colors, and these colors differ between styles. We have had several mistakes when the artists mixed up the swatches and use the wrong one for a particular style.

So, what I need is to find a way to automatize this operation and reduce errors. The ideal way would be to create a script that allows the artist to enter the style number and with that information open the AI template correspondent to that style as well as the related swatches. However, I have read in some forums that it is not possible to open a swatch library from a script. Another idea that came into my mind is to somehow open the swatches as default every time an specific AI template is open. Is that possible? Remember that each default should be different for each AI template.

I appreciate all the help you can provide me.

Thanks.

This topic has been closed for replies.
Correct answer Disposition_Dev

Not sure who told you you can't open a swatch library with a script or why they told you that.. here's a simple script my team uses:

#target Illustrator

//  insert your path here, or a file picker prompt

var theFile = new File('path/to/file/file_name.ai');

var openOpt = new OpenOptions();

//  get swatches

openOpt.openAs=LibraryType.SWATCHES;

open(theFile,null,openOpt);

then it's just a matter of setting variables for your different swatch libraries and using a prompt or scriptUI window to open the correct library.

3 replies

beymigAuthor
Known Participant
November 20, 2015

Thanks William! This was just what I needed.

I already managed to have the script working. At least a first version. Right now what it does is to ask the user the style number and automatically opens the correspondent template and the swatches library related to the fabrics within the template.

So far so good!

Disposition_Dev
Disposition_DevCorrect answer
Legend
November 17, 2015

Not sure who told you you can't open a swatch library with a script or why they told you that.. here's a simple script my team uses:

#target Illustrator

//  insert your path here, or a file picker prompt

var theFile = new File('path/to/file/file_name.ai');

var openOpt = new OpenOptions();

//  get swatches

openOpt.openAs=LibraryType.SWATCHES;

open(theFile,null,openOpt);

then it's just a matter of setting variables for your different swatch libraries and using a prompt or scriptUI window to open the correct library.

Larry G. Schneider
Community Expert
Community Expert
November 17, 2015

An AI template file is just an ordinary AI file with a tag which opens each time as an untitled document. As such it can have an associated built in swatch library. Redo the templates by opening each, add the required swatch libraries and resave, overwriting the existing template.

beymigAuthor
Known Participant
November 17, 2015

Hi Larry, thank you for your answer.

When I do that, the next time I open the template it only shows me in the swatches, the colors that are currently being used. But I need the entire pallette because the main point is the artists can switch between different colors according to the client's requirements.

I'm new with Illustrator so please forgive my little knowledge.

Thanks again.

Larry G. Schneider
Community Expert
Community Expert
November 17, 2015

I'm confused. If all the color swatches are available, doesn't that add to the confusion. If you make a template for each style with only the appropriate swatches, isn't that what you want?