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

Dynamic Actions - Delete Unused Swatches

Explorer ,
Aug 14, 2020 Aug 14, 2020

Copy link to clipboard

Copied

Hi All,

I was able to get Silly-V's dynamic actions tutorial to work for some pathfinder commands that I needed access to. I have now tried it with selecting and deleting unused swatches, but it does nothing. I set app.userInteractionLevel = UserInteractionLevel.DONTDISPLAYALERTS, thinking the alert that is given when you delete the swatches was the problem but no luck. Any help would be appreciated.

 

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 1',
        '/parameterCount 1',
        '/parameter-1 {',
        '/key 1835363957',
        '/showInPalette 4294967295',
        '/type (enumerated)',
        '/name [ 13',
        '    44656c65746520537761746368',
        ']',
        '/value 3',
        '}',
        '}',
        '}'
   ].join('\n')
        $.writeln('hit')
        doc = app.activeDocument
        var aiFile = doc.fullName.fsName
        var dirArray = aiFile.split('/');
        dirArray[dirArray.length-1] = 'unusedsw.aia'
        var newPath = dirArray.join('/')
        var f = new File(newPath)
        f.open('w')
        f.write(actionString)
        f.close()
        app.loadAction(f)
        app.doScript('unusedsw', 'swtchdel')
        app.unloadAction('unusedsw', '');
        f.remove();
}
TOPICS
Scripting

Views

384

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

Hi,

The above code will run when document is alreday saved and tosuppress the dialog which comes to confirm to delete swatches can be done by changing value of showDialog 1 to showDialog 0. Below is the complete snippet, that will run even if documenr is not saved. I have commented that part. Also suppress the dialog.

 

function unusedSwatch(){
    actionString = [
        '/version 3',
        '/name [ 8',
        '756e757365647377',
        ']',
        '/isOpen 1',
        '/actionCount 1',
 
...

Votes

Translate

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

Copy link to clipboard

Copied

Hi,

The above code will run when document is alreday saved and tosuppress the dialog which comes to confirm to delete swatches can be done by changing value of showDialog 1 to showDialog 0. Below is the complete snippet, that will run even if documenr is not saved. I have commented that part. Also suppress the dialog.

 

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')
        // doc = app.activeDocument
        // var aiFile = doc.fullName.fsName
        // var dirArray = aiFile.split('/');
        // dirArray[dirArray.length-1] = 'unusedsw.aia'
        // var newPath = dirArray.join('/')
        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();

Hope 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
Valorous Hero ,
Aug 17, 2020 Aug 17, 2020

Copy link to clipboard

Copied

The action set name and action name are switched - Charu's example is reversed.

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

Copy link to clipboard

Copied

LATEST

Hi Vasily,

I think syntax is like, if I am not wrong 🙂

app.doScript('Action Name','Set Name')

I tried in reverse way but it did not work for me.

 

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