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

Streamline ScriptingListener code?

Explorer ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

Hello All

as i'm pretty new to scripting for PS and i haven't found an answer to this. Is there a good resource page (i haven't found) or a tutorial about it?

  • Does it make sense or is it even possible to streamline the code generated by the ScriptingListener plugin?

I have the following code and it would be awesome to combine it into one function and get rid of unnecessary code:

function Selecttexures() {

  // Select

  function step1(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putName(cTID('Lyr '), "LIGHT FABRIC TEXTURE");

    desc1.putReference(cTID('null'), ref1);

    desc1.putBoolean(cTID('MkVs'), false);

    var list1 = new ActionList();

    list1.putInteger(43);

    desc1.putList(cTID('LyrI'), list1);

    executeAction(cTID('slct'), desc1, dialogMode);

  };

  // Select Linked Layers

  function step2(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));

    desc1.putReference(cTID('null'), ref1);

    executeAction(sTID('selectLinkedLayers'), desc1, dialogMode);

  };

  // Hide

  function step3(enabled, withDialog) {

    if (enabled != undefined && !enabled)

      return;

    var dialogMode = (withDialog ? DialogModes.ALL : DialogModes.NO);

    var desc1 = new ActionDescriptor();

    var list1 = new ActionList();

    var ref1 = new ActionReference();

    ref1.putEnumerated(cTID('Lyr '), cTID('Ordn'), cTID('Trgt'));

    list1.putReference(ref1);

    desc1.putList(cTID('null'), list1);

    executeAction(cTID('Hd  '), desc1, dialogMode);

  };

  step1();      // Select

  step2();      // Select Linked Layers

  step3();      // Hide

};

TOPICS
Actions and scripting

Views

550

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
Advisor ,
Mar 20, 2017 Mar 20, 2017

Copy link to clipboard

Copied

If you still have the orginal SL code, you can use xtools\apps\ActionFileFromSLCode.jsx.

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
Explorer ,
Mar 21, 2017 Mar 21, 2017

Copy link to clipboard

Copied

LATEST

Thank you xbytor

I will check this script out (did so with some of your other scripts, thanks for that -> very useful).

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