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

Convert All Swatches to CMYK Process Global

Participant ,
Feb 03, 2025 Feb 03, 2025

Hi,

I have this working script with me which works well in InDesign. It helps me to (a) Add all Unnamed colors, (b) remove all unused swatches, and (c) convert all colours to CMYK Process.

 

I need a similar code for Illustrator with an additional check point. i.e. I want to convert all colours to CMYK Process Global swatch.

#target indesign
app.menuActions.item("$ID/Add All Unnamed Colors").invoke();
var myIndesignDoc = app.activeDocument;
var myUnusedSwatches = myIndesignDoc.unusedSwatches;

for (var s = myUnusedSwatches.length - 1; s >= 0; s--) {
  var mySwatch = myIndesignDoc.unusedSwatches[s];
  var name = mySwatch.name;
  if (name != "") {
    mySwatch.remove();
  }
}
app.activeDocument.colors.everyItem().properties = { space: ColorSpace.CMYK, model: ColorModel.PROCESS };

 Can anyone help, please.

TOPICS
How-to , Scripting
338
Translate
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
Adobe
Community Expert ,
Feb 03, 2025 Feb 03, 2025

Hi,

You can try the solution from the following link

https://community.adobe.com/t5/illustrator-discussions/illustrator-script-that-will-convert-all-spot...

 

and to remove the unused swatches, you can use the following script

function removeUnusedSwatches() {
    actionString = [
        '/version 3',
        '/name [ 8',
        '756e757365647377',
        ']',
        '/isOpen 1',
        '/actionCount 1',
        '/action-1 {',
        '/name [ 8',
        '737774636864656c',
        ']',
        '/keyIndex 0',
        '/colorIndex 0',
        '/isOpen 0',
        '/eventCount 2',
        '/event-1 {',
        '/useRulersIn1stQuadrant 0',
        '/internalName (ai_plugin_swatches)',
        '/localizedName [ 8',
        '5377617463686573',
        ']',
        '/isOpen 0',
        '/isOn 1',
        '/hasDialog 0',
        '/parameterCount 1',
        '/parameter-1 {',
        '/key 1835363957',
        '/showInPalette 4294967295',
        '/type (enumerated)',
        '/name [ 17',
        '    53656c65637420416c6c20556e75736564',
        ']',
        '/value 11',
        '}',
        '}',
        '/event-2 {',
        '/useRulersIn1stQuadrant 0',
        '/internalName (ai_plugin_swatches)',
        '/localizedName [ 8',
        '5377617463686573',
        ']',
        '/isOpen 0',
        '/isOn 1',
        '/hasDialog 1',
        '/showDialog 0',
        '/parameterCount 1',
        '/parameter-1 {',
        '/key 1835363957',
        '/showInPalette 4294967295',
        '/type (enumerated)',
        '/name [ 13',
        '    44656c65746520537761746368',
        ']',
        '/value 3',
        '}',
        '}',
        '}'
    ].join('\n')
    var f = new File(Folder.desktop + "/unusedsw.aia");
    if (f.exists) {
        f.remove();
    }
    f.open('w')
    f.write(actionString)
    f.close()
    app.loadAction(f)
    app.doScript('swtchdel', 'unusedsw')
    app.unloadAction('unusedsw', '');
    f.remove();
}

removeUnusedSwatches();

 

Best regards
Translate
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
Participant ,
Feb 04, 2025 Feb 04, 2025
LATEST

Thanks, for the inputs, Charu.

The function removeUnusedSwatches() removes all the swatches except the used Spot and Global swatches. There are other used non-global swatches as well which are getting removed.

 

Secondly, the other link you provided, was giving Error: 1224 Numeric value expected. Line 19: sw.color = newColor., but I'll figure it out.

 

I'm on MAC using Illustrator 2023, but I also work on PC with other versions of Illustrator.

 

The ONLY problem for me is I want a code that converts all the swatches to a GLOBAL swatch. Can you please help me with that.

Translate
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