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

script to create a template layer & then add a layer? Possible?

New Here ,
Dec 15, 2010 Dec 15, 2010

Copy link to clipboard

Copied

Hello, I am just starting to learn javascript and would like to know if it's possible to do the following:

  1. Open multiple .tiff or .jpg files into illustrator
  2. On each file's layer 1, template = yes (it's a check box) and click OK
  3. Add new layer 2, click OK
  4. Save file
  5. Close file

I tried creating an action to do this, but it does not work. I am doing some illustrator and photoshop work which has quite a lot of repetitive tasks & I know a script would be a huge timesaver.  This is just one of several scripts that I'd like to learn how to write.  Thanks very much for reading this post and for your help.  Best, Nancy

TOPICS
Scripting

Views

1.6K

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
Adobe
Community Expert ,
Dec 16, 2010 Dec 16, 2010

Copy link to clipboard

Copied

That's odd. According to the JS Object Model Viewer, you can change about everything in the standard Layer Option dialog using a script (print, preview, locked, visible, and even "dimPlacedImages") but not ... "template".

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
Enthusiast ,
Nov 10, 2016 Nov 10, 2016

Copy link to clipboard

Copied

is there a change to this? i'm trying to do the same.

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 ,
Nov 10, 2016 Nov 10, 2016

Copy link to clipboard

Copied

You can use an action to do this. (play action with your script)

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
Engaged ,
Nov 11, 2016 Nov 11, 2016

Copy link to clipboard

Copied

I tried it (embed this action into the script)  – it's works! Thank you, Vasily!

This code sets attribute "Template" to the current layer:

act_setLayTmplAttr();

function act_setLayTmplAttr () {

    var str = '/version 3' + '/name [ 14' + ' 7365744c6179546d706c41747472' + ']' + '/isOpen 1' + '/actionCount 1' + '/action-1 {' + ' /name [ 14' + ' 7365744c6179546d706c41747472' + ' ]' + ' /keyIndex 0' + ' /colorIndex 0' + ' /isOpen 1' + ' /eventCount 1' + ' /event-1 {' + ' /useRulersIn1stQuadrant 0' + ' /internalName (ai_plugin_Layer)' + ' /localizedName [ 5' + ' 4c61796572' + ' ]' + ' /isOpen 1' + ' /isOn 1' + ' /hasDialog 1' + ' /showDialog 0' + ' /parameterCount 10' + ' /parameter-1 {' + ' /key 1836411236' + ' /showInPalette -1' + ' /type (integer)' + ' /value 4' + ' }' + ' /parameter-2 {' + ' /key 1851878757' + ' /showInPalette -1' + ' /type (ustring)' + ' /value [ 20' + ' 4c61796572732050616e656c204f7074696f6e73' + ' ]' + ' }' + ' /parameter-3 {' + ' /key 1953068140' + ' /showInPalette -1' + ' /type (ustring)' + ' /value [ 7' + ' 4c617965722031' + ' ]' + ' }' + ' /parameter-4 {' + ' /key 1953329260' + ' /showInPalette -1' + ' /type (boolean)' + ' /value 1' + ' }' + ' /parameter-5 {' + ' /key 1936224119' + ' /showInPalette -1' + ' /type (boolean)' + ' /value 1' + ' }' + ' /parameter-6 {' + ' /key 1819239275' + ' /showInPalette -1' + ' /type (boolean)' + ' /value 1' + ' }' + ' /parameter-7 {' + ' /key 1886549623' + ' /showInPalette -1' + ' /type (boolean)' + ' /value 1' + ' }' + ' /parameter-8 {' + ' /key 1886547572' + ' /showInPalette -1' + ' /type (boolean)' + ' /value 0' + ' }' + ' /parameter-9 {' + ' /key 1684630830' + ' /showInPalette -1' + ' /type (boolean)' + ' /value 1' + ' }' + ' /parameter-10 {' + ' /key 1885564532' + ' /showInPalette -1' + ' /type (unit real)' + ' /value 50.0' + ' /unit 592474723' + ' }' + ' }' +

      '}';

  var f = new File ('~/ScriptAction.aia');

  f.open ('w');

  f.write (str);

  f.close ();

  app.loadAction (f);

  f.remove ();

  app.doScript ("setLayTmplAttr", "setLayTmplAttr", false); // action name, set name

  app.unloadAction ("setLayTmplAttr", ""); // set name

}

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

I converted my own action for Make Color Group. Issue is i get 2 errors. one is that it cant play the action, second it returns error when removing it again.

 

Do you have any idea?

below is my version, ive added aia code so i could compare and alter your code more easily

 

// Omarat
// https://community.adobe.com/t5/illustrator-discussions/script-to-create-a-template-layer-then-add-a-layer-possible/m-p/3111687#M154564
// Example used for Make Color Group
/*
    original aia action

    /version 3
    /name [ 11
        4c6f676f2d5061636b6572
    ]
    /isOpen 1
    /actionCount 1
    /action-1 {
        /name [ 16
            4d616b6520436f6c6f722047726f7570
        ]
        /keyIndex 0
        /colorIndex 1
        /isOpen 1
        /eventCount 1
        /event-1 {
            /useRulersIn1stQuadrant 0
            /internalName (ai_plugin_swatches)
            /localizedName [ 8
                5377617463686573
            ]
            /isOpen 0
            /isOn 1
            /hasDialog 1
            /showDialog 1
            /parameterCount 1
            /parameter-1 {
                /key 1835363957
                /showInPalette -1
                /type (enumerated)
                /name [ 15
                    4e657720436f6c6f722047726f7570
                ]
                /value 17
            }
        }
    }

*/
act_MakeColorGroup();

function act_MakeColorGroup () {
    var str = '/version 3' + 
                '/name [ 11' + 
                    ' 4c6f676f2d5061636b6572' + 
                ']' + 
                '/isOpen 1' + 
                '/actionCount 1' + 
                '/action-1 {' + 
                    ' /name [ 16' + 
                        ' 4d616b6520436f6c6f722047726f7570' + 
                    ' ]' + 
                    ' /keyIndex 0' + 
                    ' /colorIndex 1' + 
                    ' /isOpen 1' + 
                    ' /eventCount 1' + 
                    ' /event-1 {' + 
                        ' /useRulersIn1stQuadrant 0' + 
                        ' /internalName (ai_plugin_swatches)' + 
                        ' /localizedName [ 8' + 
                            ' 5377617463686573' + 
                        ' ]' + 
                        ' /isOpen 0' + 
                        ' /isOn 1' + 
                        ' /hasDialog 1' + 
                        ' /showDialog 1' + 
                        ' /parameterCount 1' + 
                        ' /parameter-1 {' + 
                            ' /key 1835363957' + 
                            ' /showInPalette -1' + 
                            ' /type (enumerated)' + 
                            '/name [ 15' + 
                                ' 4e657720436f6c6f722047726f7570' + 
                            ']' + 
                            '/value 17' + 
                        '}' + 
                    '}' + 
                '}';
  var f = new File ('~/MakeColorGroup.aia');
  f.open ('w');
  f.write (str);
  f.close ();
  app.loadAction (f);
  app.doScript ("Make Color Group", "Logo Packer", true); // action name, set name
  app.unloadAction ("Make Color Group", ""); // set name
  f.remove ();

}


the action and action group is created, but wont play. Weird thing is is when the group is selected you can actually press play, but it wont do it?! I wasnt sure what false does in doScript, neither false nor true work 

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 ,
Jul 14, 2022 Jul 14, 2022

Copy link to clipboard

Copied

LATEST

Ive found my isse 🙂 its a dash ion the Action Group folder name, when i add it, it does work

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
Engaged ,
Nov 11, 2016 Nov 11, 2016

Copy link to clipboard

Copied

NYC_Nancy, hello!

What you do not specifically work?

Which of the above points, you can not describe in the script?

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