Illustrator script: apply swatch from library
Hi,
I'm working on a script to apply a swatch from a library to a pathItem and the color name to a textFrame.
It works, the problem is it crashes when I close the file with the PMS Library. Any help would be very appreciated.
Here is my code.
#target Illustrator
var docRef = app.activeDocument;
var docRef1 = app.open(File("~/Documents/PMSLibrary.ai"));
// Get specific swatch
var PMSColor = docRef1.swatches.getByName('PANTONE 100 C');
// Add Swatch to Original Document
var AddColor = docRef.swatches.add();
AddColor.name = PMSColor.name;
AddColor.color = PMSColor.color
// Add text frame and pathItem
var ColorFrame = docRef.textFrames.add('Color')
var ColorBox = docRef.pathItems.add('Box')
// Assign to Text Frame
ColorFrame.contents = PMSColor.name
// Assign color to PathItem
ColorBox.fillColor = PMSColor.color
// Close reference document
docRef1.close(SaveOptions.DONOTSAVECHANGES);
app.redraw();;
Thanks!
