Skip to main content
Known Participant
October 2, 2015
Answered

Merging swatches

  • October 2, 2015
  • 1 reply
  • 3135 views

Hello everyone,

I was wondering if there was a way to merge swatches via script. I only see ways to add or delete.

Thanks!

This topic has been closed for replies.
Correct answer elDudereno

yea exactly, thanks


Re: Batch replace color with another color

#target illustrator

var docRef = app.activeDocument;

with (docRef) {

    var replaceColor = swatches.getByName('PANTONE 101 C').color;

    for (var i = 0; i < pathItems.length; i++) {

    with (pathItems) {

        if (filled == true && fillColor instanceof SpotColor) {

            if (fillColor.spot.name == 'PANTONE 133 C') fillColor = replaceColor;

        }

        if (stroked == true && strokeColor instanceof SpotColor) {

            if (strokeColor.spot.name == 'PANTONE 133 C') strokeColor = replaceColor;

            }

        }

    }

   

    for (var j = 0; j < stories.length; j++) {

        with (stories) {

            for (var k = 0; k < characters.length; k++) {

                with (characters.characterAttributes) {

                    if (fillColor instanceof SpotColor) {

                        if (fillColor.spot.name == 'PANTONE 133 C') fillColor = replaceColor;

                    }

                    if (strokeColor instanceof SpotColor) {

                        if (strokeColor.spot.name == 'PANTONE 133 C') strokeColor = replaceColor;

                    }

                }

            }

        }

    }

}

1 reply

Vinicius Baptista
Inspiring
October 2, 2015

Hello man,

I don't understand what kind of merge you want to do, sum your values in new swatche? For example swatche x: cyan = 50 | magenta = 30 | yellow = 0 | black = 10, swatche y: cyan = 10 | magenta = 10 | yellow = 10 | black = 10, swatch result = cyan = 60 | magenta = 40 | yellow = 10 | black = 20.

what purpose of this?

Best regards

Vinícius

Inspiring
October 2, 2015

I assume he means like this, but with a script.

elDuderenoCorrect answer
Inspiring
October 2, 2015

yea exactly, thanks


Re: Batch replace color with another color

#target illustrator

var docRef = app.activeDocument;

with (docRef) {

    var replaceColor = swatches.getByName('PANTONE 101 C').color;

    for (var i = 0; i < pathItems.length; i++) {

    with (pathItems) {

        if (filled == true && fillColor instanceof SpotColor) {

            if (fillColor.spot.name == 'PANTONE 133 C') fillColor = replaceColor;

        }

        if (stroked == true && strokeColor instanceof SpotColor) {

            if (strokeColor.spot.name == 'PANTONE 133 C') strokeColor = replaceColor;

            }

        }

    }

   

    for (var j = 0; j < stories.length; j++) {

        with (stories) {

            for (var k = 0; k < characters.length; k++) {

                with (characters.characterAttributes) {

                    if (fillColor instanceof SpotColor) {

                        if (fillColor.spot.name == 'PANTONE 133 C') fillColor = replaceColor;

                    }

                    if (strokeColor instanceof SpotColor) {

                        if (strokeColor.spot.name == 'PANTONE 133 C') strokeColor = replaceColor;

                    }

                }

            }

        }

    }

}