Skip to content

Instantly share code, notes, and snippets.

@JolinM
Last active January 3, 2016 03:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JolinM/8401674 to your computer and use it in GitHub Desktop.
Save JolinM/8401674 to your computer and use it in GitHub Desktop.
Illustrator plot file
activeDoc();
//multiplicateur, changer la valeur si désiré
var multiplier = "1";
function activeDoc() {
if (app.documents.length == 0) {
alert("No document open");
return;
} else {
//remove black
try {
app.activeDocument.swatches.getByName("Black").remove();
}
catch (e){}
//add Black swatch
addBlack ();
//replace spot color by rgb value
replaceGlobalColor();
}
}
function addBlack () {
var newSwatch = app.activeDocument.swatches.add();
newSwatch.name = "Black";
newSwatch.gray = 100;
}
function replaceGlobalColor() {
var doc, count, rgb, value, swat;
doc = app.activeDocument, count = doc.spots.length;
for ( var i = 0; i < count; i++ ) {
if ( doc.spots[i].colorType == ColorModel.PROCESS ) {
value = doc.spots[i].getInternalColor();
swat = doc.swatches.add();
swat.name = doc.spots[i].name;
rgb = new RGBColor();
rgb.red = value[0];
rgb.green = value[1];
rgb.blue = value[2];
swat.color = rgb;
};
};
if ( count > 0 ) { doc.spots.removeAll(); }
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment