Highlighted

Illustrator script to remove the unwanted swatches

Explorer ,
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

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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.

 

Topics

Scripting

Views

72

Likes

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

Illustrator script to remove the unwanted swatches

Explorer ,
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

Adobe Community Professional
Correct answer by Charu Rajput | Adobe Community Professional

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.

 

Topics

Scripting

Views

73

Likes

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
Aug 14, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Aug 14, 2020 1
Explorer ,
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?

Likes

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
Reply
Loading...
Aug 20, 2020 0
Adobe Community Professional ,
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

Likes

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
Reply
Loading...
Aug 20, 2020 1
Enthusiast ,
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

 

 

Likes

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
Reply
Loading...
Aug 21, 2020 0