JSX - How to reference swatch in a loaded swatch library in an AIT?
Hi all, I want to set up AITs with preloaded swatch libraries. Is there a way to reference those swathes without having to copy the swatches over into the main doc swatch library programmatically?
I did set up a routine to do that, but, while it works sometimes, occassionally I get a PARM error. This is the routine I'm using; instead of loading the ASE, I am loading the swatch ai file ("theFile"). To reference the existing swatch library, I've tried just a regular activeDocument.swatches.getByName("theName"), where the ait is the active doc, as well as app.documents.getByName("libraryname").swatches.getByName("theName"), both of which yield No Such Element.
//open the swatch library and return its swatches
var openSwatches = function(doc, theFile) {
//var openOpt = new OpenOptions();
// get swatches
var sd = app.open(theFile);
var sws = sd.swatches;
var i = sws.length;
var a = []; //array of swatch names to return
var s, ns, cs;
while(i--) {
s = sws[i];
//skip default swatches
if(s.name == "[Registration]" || s.name == "[None]"){
continue;
}
//remove the swatch if it exists already
try {
cs = doc.swatches.getByName(s.name);
cs.remove();
} catch(e) {}
//do spots
if (s.color.typename === "SpotColor") {
ns = doc.spots.add();
ns.color = s.color.spot.color;
ns.colorType = ColorModel.SPOT;
}
//do nonspots
else {
ns = doc.swatches.add();
ns.color= s.color;
}
ns.name = s.name;
a.push(ns.name);
}
sd.close(SaveOptions.DONOTSAVECHANGES);
}

