• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Activate the Global option on Swatch options - Illustrator Script

Explorer ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

Hello!

Do you know how to activate the Global option on Swatch options in Illustrator using a Script?


1941EE06-E10B-417E-B5B2-27721AD65C2F.jpeg

TOPICS
Scripting

Views

823

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 27, 2020 Jun 27, 2020

Hi Robsmith01, it seems a bit complicated due to the structure of colors in Illustrator. There are swatches and colors and spotColors and spots.

 

Check out the convertSelectedSwatchesToGlobal function below to give you a practical idea. It expects you to select swatch(es) in the Swatch Palette first. Or just call the individual function convertSwatchToGlobal with a single Swatch object passed in.

 

function convertSelectedSwatchesToGlobal() {
    var swatches = app.activeDocument.swatches.getSelect
...

Votes

Translate

Translate
Adobe
Community Expert ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

Hi Robsmith01, it seems a bit complicated due to the structure of colors in Illustrator. There are swatches and colors and spotColors and spots.

 

Check out the convertSelectedSwatchesToGlobal function below to give you a practical idea. It expects you to select swatch(es) in the Swatch Palette first. Or just call the individual function convertSwatchToGlobal with a single Swatch object passed in.

 

function convertSelectedSwatchesToGlobal() {
    var swatches = app.activeDocument.swatches.getSelected();
    for (var i = 0; i < swatches.length; i++) {
        convertSwatchToGlobal(swatches[i]);
    }
}

function convertSwatchToGlobal(swatch) {
    if (swatch.color.typename == 'CMYKColor' || swatch.color.typename == 'RGBColor') {
        var newSpot = app.activeDocument.spots.add();
        newSpot.name = swatch.name;
        newSpot.colorType = ColorModel.PROCESS;
        newSpot.color = swatch.color;
        var newSpotColor = new SpotColor();
        newSpotColor.spot = newSpot;
        swatch.remove()
    }
}

convertSelectedSwatchesToGlobal();

  

One side effect is that the converted swatches will all be moved to the end of the swatches list, unless yours is sorted.

 

Regards,

Mark

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jun 29, 2020 Jun 29, 2020

Copy link to clipboard

Copied

LATEST

It was very useful!

Thanks!

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jun 27, 2020 Jun 27, 2020

Copy link to clipboard

Copied

is this all you want to do? if checking Global is not a requirements of a larger script then you could select the swatches manually and check the option. All selected swatches will be affected in one go.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines