Copy link to clipboard
Copied
I have a script where I'm replacing swatches with others and I'm not able to replace a tinted swatch, it just ignores it. Any tips to get this script to find my 90% tint swatch and replace it?
var myDoc = app.activeDocument;
//replace swatches
try { myDoc.colors.item("PANTONE 426 C 90%").remove("PANTONE 426 C");}
catch (e) {}
Hi @LynxKx, here's some code to point you in the right direction. I've made a function that removes all tints of a particular color. The main points are that "tints" are different objects to "colors", and have a baseColor property that points to the actual color.
- Mark
removeTintsOfColor(app.activeDocument, 'MyColor');
function removeTintsOfColor(doc, colorOrName) {
var color;
if (colorOrName.constructor.name == 'String') {
color = doc.swatches.itemByName(colorOrName);
} el
...
Copy link to clipboard
Copied
Hi @LynxKx, here's some code to point you in the right direction. I've made a function that removes all tints of a particular color. The main points are that "tints" are different objects to "colors", and have a baseColor property that points to the actual color.
- Mark
removeTintsOfColor(app.activeDocument, 'MyColor');
function removeTintsOfColor(doc, colorOrName) {
var color;
if (colorOrName.constructor.name == 'String') {
color = doc.swatches.itemByName(colorOrName);
} else if (colorOrName.constructor.name == 'Color') {
color = colorOrName;
}
if (color == undefined || !color.isValid) return;
var tints = doc.tints;
for (var i = tints.length - 1; i >= 0; i--) {
if (tints[i].baseColor == color)
tints[i].remove();
}
}
Copy link to clipboard
Copied
perfect! thank you so much!!