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

illustrator action script error

Participant ,
Oct 27, 2020 Oct 27, 2020

Hi Guys,

 

Thew below code doesn't load the action into the illustrator. Could anyone help me to resolve this.

addUsedColors()

function addUsedColors() {
    if (app.documents.length = 0) {
        return;
    }
    var ActionSet = "colors"
    var Action1Name = "add used colors"

    var ActionString = '/version 3\n/name [ 6\n' + Hexit(ActionSet) + '\n]\n/isOpen 0\n/actionCount 1\n/action-1 {\n /name [ 15\n'+ Hexit(Action1Name) + '\n ]\n /keyIndex 0\n /colorIndex 0\n /isOpen 1\n /eventCount 1\n /event-1 {\n /useRulersIn1stQuadrant 0\n /internalName (ai_plugin_swatches)\n /localizedName [ 8\n 5377617463686573\n ]\n /isOpen 0\n /isOn 1\n /hasDialog 0\n /parameterCount 2\n /parameter-1 {\n /key 1835363957\n /showInPalette 4294967295\n /type (enumerated)\n /name [ 15\n 416464205573656420436f6c6f7273\n ]\n /value 9\n }\n /parameter-2 {\n /key 1634495605\n /showInPalette 4294967295\n /type (boolean)\n /value 1\n }\n }\n}';

    createAction(ActionString, ActionSet);
    ActionString = null;
    app.doScript(Action1Name, ActionSet, false);
    app.unloadAction(ActionSet, "");

    function createAction(str, act) {
        var f = new File("~/Desktop" + act + '.aia');
        f.open('w');
        f.write(str);
        f.close();
        app.loadAction(f);
        f.remove();
    }

    function Hexit(str) {
        var hex = '';
        for (var i = 0; i < str.length; i++) {
            hex += '' + str.charCodeAt(i).toString(16);
        }
        return hex;
    }
}

Error

 

Screenshot 2020-10-27 at 4.45.02 PM.png

 

TOPICS
Scripting
742
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

correct answers 1 Correct answer

Community Expert , Oct 27, 2020 Oct 27, 2020

HI Raghav,

I have tried your script and it works perfectly fine without any error in Illustrator CC 2021.

Could you please tell us which version of Illustrator are using to run this script. 

Translate
Adobe
Community Expert ,
Oct 27, 2020 Oct 27, 2020

HI Raghav,

I have tried your script and it works perfectly fine without any error in Illustrator CC 2021.

Could you please tell us which version of Illustrator are using to run this script. 

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 ,
Oct 27, 2020 Oct 27, 2020

CC19 &20. Its load the action? bue it my version it shows error.

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
Community Expert ,
Oct 27, 2020 Oct 27, 2020

Yes, it loads the action and sucessfully add the swatches too. Let me do testing for CC 2020. I can't do testing in CC 2019 as it will not be available in CC app. I will update you after testing in CC 2020

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
Community Expert ,
Oct 27, 2020 Oct 27, 2020

Working perfectly in CC 2020 as well.

How are you trying to execute the script?

 

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 ,
Oct 27, 2020 Oct 27, 2020

Just load the script through script option from the menu...

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
Community Expert ,
Oct 27, 2020 Oct 27, 2020
LATEST

It is perfectly fine from scripts option too. Please attach your ai sample file. It may be some other issue. There is no issue in the script. Or try some other action whether it is working or not.

 

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