bodich
bodich

Reputation: 2235

How to make swatch Global with Illustrator Script?

I need to add a swatch that will be tightly linked with pathItem. But it's possible only when swatch is Global. I need it for special printer that is printing all pathItems with this swatch using special ink. Special swatch is white. And I cannot remove other white swatches as I don't need all white areas printed with special ink. (I understand that I can do manually but we need script) So... Anybody know how to make swatch Global using script? Thank you.

Upvotes: 2

Views: 1201

Answers (1)

bodich
bodich

Reputation: 2235

I figured out how to solve that. It has to be separated object called Spot. My code is more complex so I will paste code I found on adobe forums, it's just shorter. You can skip swatch creation, new swatch will be automatically added with the same name as newSpot. You can assign swatch's color to pathItem (not newSpot directly) and spot will be linked to pathItem's color.

addSpot ('FOIL', 10, 0, 100, 0);  

function addSpot(name, c, m, y, k) {  
    try {  
        swatch = app.activeDocument.swatches[name]; // if swatch exists....  
        addSpot (name+='1', c, m, y, k); // ...add 1 to swatch name  
    }  
    catch (e) {  
        var newSpot = app.activeDocument.spots.add();  
        newSpot.name = name;  

        var newColor = new CMYKColor();  
        newColor.cyan = c;  
        newColor.magenta = m;  
        newColor.yellow = y;  
        newColor.black = k;  


        newSpot.colorType = ColorModel.SPOT;  
        newSpot.color = newColor;  
        var newSpotColor = new SpotColor();  
        newSpotColor.spot = newSpot;  
    }  
}  

Upvotes: 2

Related Questions