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

Illustrator script to remove the unwanted swatches

Participant ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Hi Everyone ,

Im trying to remove the unwanted swatches in my document. But it would not work. Could anyone help me to remove the unwanted swatches in the active document

TOPICS
Scripting

Views

1.2K

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 , Aug 20, 2020 Aug 20, 2020

Hi Raghav,

There is no direct API to delete the unused swatches. This possible via action only. There is another way of doing this but in the end it also using actions. Try following code

 

 

function unusedSwatch(){
    actionString = [
        '/version 3',
        '/name [ 8',
        '756e757365647377',
        ']',
        '/isOpen 1',
        '/actionCount 1',
        '/action-1 {',
        '/name [ 8',
        '737774636864656c',
        ']',
        '/keyIndex 0',
        '/colorIndex 0'
...

Votes

Translate

Translate
Community Expert ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Hi,

You can record the action and execute the action using script. I have recorded the action, you can download the action file from. below link and make sure to keep this file on your desktop. Following is the script to execute the action file

 

Action File 

 

var actionFile = File(Folder.desktop + "/Delete Unused Swatches.aia");
app.loadAction(actionFile);
app.doScript('Delete Unused Swatches', 'Set 1');
app.unloadAction('Set 1', '');

Let us know if this works for you.

 

Best regards

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
Participant ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

Hi Charu,

Thanks for your update. Is there any possible way for delete the unwanted swatches without making actions file?

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 ,
Aug 20, 2020 Aug 20, 2020

Copy link to clipboard

Copied

Hi Raghav,

There is no direct API to delete the unused swatches. This possible via action only. There is another way of doing this but in the end it also using actions. Try following code

 

 

function unusedSwatch(){
    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')
        $.writeln('hit')
        var f = new File(Folder.desktop + "/unusedsw.aia");
        f.open('w')
        f.write(actionString)
        f.close()
        app.loadAction(f)
        app.doScript('swtchdel','unusedsw')
        app.unloadAction('unusedsw', '');
        f.remove();
}

unusedSwatch();

 

 

The difference here is action string is in the code instead of separate file. It also creating a file in the background but also removing it. For me it is almost same solution just a different way of doing that.

 

Best regards

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
Advocate ,
Aug 21, 2020 Aug 21, 2020

Copy link to clipboard

Copied

Salut!

Activer le menu de la palette...

et choisir "Sélectionner les nuances non utilisées

Puis faire glisser la sélection dans la corbeille.

renél80416020_0-1598014841246.png

de elleere

 

 

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
New Here ,
May 06, 2023 May 06, 2023

Copy link to clipboard

Copied

Please upload code unable to downlaod action file. 

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 ,
May 07, 2023 May 07, 2023

Copy link to clipboard

Copied

LATEST

you can record your own Action to try first script, or use the second script Charu posted, that one does not require the action to be present.

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