Skip to main content
Participating Frequently
November 28, 2024
Question

Swatches - Turn percentage on all swatches below (x) to zero?

  • November 28, 2024
  • 1 reply
  • 281 views

Hello everyone,

Is there is a way to quicken the process of changing the values of mutiple swatches simultaneously insted of clicking each one manualy.

 

For example I have 50 swatches but I dont want any of them to be below 6 percent in CMYK  so I have to manually lower all the values of cmyk for each one individually.

 

Ty in advance.

I hope I was clear enough.

 

 

This topic has been closed for replies.

1 reply

m1b
Community Expert
Community Expert
November 28, 2024

Hi @DRAGAN28437974li3z, try this script. It's pretty basic but it does what you describe.

- Mark

 

(function () {

    // no CMYK lower than 6%
    const minColorPercent = 6;

    var doc = app.activeDocument,
        swatches = doc.swatches;

    for (var i = 0, swatch; i < swatches.length; i++) {

        swatch = swatches[i];

        if ('CMYKColor' !== swatch.color.typename)
            continue;

        swatch.color.cyan = Math.max(minColorPercent, swatch.color.cyan);
        swatch.color.magenta = Math.max(minColorPercent, swatch.color.magenta);
        swatch.color.yellow = Math.max(minColorPercent, swatch.color.yellow);
        swatch.color.black = Math.max(minColorPercent, swatch.color.black);

    }

})();

Participating Frequently
November 28, 2024

Hi m1b,

this is very close to the thing I asked but I didnt explain it well.

 

Now everything that was on 0 goes to 6% but I thought if,

for example 

 

C is 5,4% goes to 0

M 10% stays 10%

Y 88% stays 88%

K 3,3% goes to 0%

 

 

 

 

 

 

m1b
Community Expert
Community Expert
November 28, 2024

Ah! I see. How about this?

(function () {

    // no CMYK ink lower than this threshold %
    const inkCutOff = 6;

    var doc = app.activeDocument,
        swatches = doc.swatches;

    for (var i = 0, color; i < swatches.length; i++) {

        color = swatches[i].color;

        if ('SpotColor' === color.typename)
            color = color.spot.color;

        if ('CMYKColor' !== color.typename)
            continue;

        process(color, 'cyan');
        process(color, 'magenta');
        process(color, 'yellow');
        process(color, 'black');

    }

    function process(color, key) {
        if (color[key] <= inkCutOff)
            color[key] = 0;
    };

})();