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

How to pass parameters to automation plugin to Javascript

Explorer ,
Mar 20, 2015 Mar 20, 2015

Hello,

We can call automation plugin from java script below code.

var xx = stringIDToTypeID( "459ac2e6-82d1-11d5-9879-00b0d0201111" );     // Has will be the unique ID for this plugin

executeAction( xx, undefined, DialogModes.NO );

I am trying to passing parameters for the same plugin.

I tried to find a way myself following plug-in resource guide but there information is not so clear.

Can you tell me,

  1. How to define parameters in terminology file. (my guess it should be define in terminology file)
  2. How to JS call with parameters
  3. And how to extract those parameters inside plugin.

Sample Pipl.r file  (This is from C++ plugin in SDK)

//-------------------------------------------------------------------------------

// Dictionary (scripting) resource

//-------------------------------------------------------------------------------

resource 'aete' (16000, "Getter dictionary", purgeable)

  {

       1, 0, english, roman, /* aete version and language specifiers */

       {

            "Testing", /* vendor suite name */

            "Adobe example plug-ins", /* optional description */

            'get ', /* suite ID */

            1, /* suite code, must be 1 */

            1, /* suite level, must be 1 */

       { /* structure for automation */

       plugInName, /* name */

       "No comment", /* optional description */

       'get ', /* class ID, must be unique or Suite ID */

       'getr', /* event ID, must be unique */

       NO_REPLY, /* never a reply */

            IMAGE_DIRECT_PARAMETER, /* direct parameter, used by Photoshop */   <-- According to the documentation, I guess here should be come parameters.  (para name, keyID, typeID )

            { // filter or selection class here:

            }

      },

  {}, /* non-filter/automation plug-in class here */

  {}, /* comparison ops (not supported) */

  { // Enumerations go here:

  } /* end of any enumerations */

  }

  };

// end GetterPiPL.r

Thank you.

TOPICS
Actions and scripting
1.1K
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
Adobe
Community Expert ,
Mar 20, 2015 Mar 20, 2015

I do not know Javascript or Photoshop Scripting I only hack at it by looking  at others code.   I can tell you what I have seen.   Photoshop's Fit Image plug-in these days is a Plug-in that is implemented in JavaScript.   That means the Script is written as a Photoshop Plug-in and when recorded in a  action the script will record the setting used while recording the Action into the action step.  When the action is played the action step will pass the recorded setting to the fit image plug-in script and the Fit Image script will bypass displaying its dialog.  I have also seen code in the Image Processor script where it passes setting  from its dialog to the Fit Image Plug-in script  to have it fit the current document to size.  Fit image does not display it dialog it users the values passed from the Image Processor script.  The Image Processor script uses the action manager interface to do that.  This is what that code looks like.  From Image Processor.jsx.  I do not know C,  C++or c# at all.  I hope what I have seen helps you....  The key seem to be you need to know not  only the plug-in's UUID you also need to know its dialog.  Perhaps recording an Action step that uses the plugin you want to use then expanding the action  step recorded for the plugin will shed some light on how to pass setting for its dialog. Installing Adobe's Scriplistener plug-in should record the required javascript code that you can modify.

// use the fit image automation plug-in to do this work for me

function FitImage( inWidth, inHeight ) {

     if ( inWidth == undefined || inHeight == undefined ) {

          alert( strWidthAndHeight );

          return;

          }

    var desc = new ActionDescriptor();

    var unitPixels = charIDToTypeID( '#Pxl' );

    desc.putUnitDouble( charIDToTypeID( 'Wdth' ), unitPixels, inWidth );

    desc.putUnitDouble( charIDToTypeID( 'Hght' ), unitPixels, inHeight );

    var runtimeEventID = stringIDToTypeID( "3caa3434-cb67-11d1-bc43-0060b0a13dc4" );

    executeAction( runtimeEventID, desc, DialogModes.NO );

}

JJMack
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
Explorer ,
Mar 23, 2015 Mar 23, 2015
LATEST

Hello Mack,

Thanks for your detail explanation.

Actually, I haven't much play with PS javascripting plugins niter Fit image.

The key points I have figure out that, the way you attached parameters to descriptor and point of finding some light from listener.

That made me a conceptual idea, although I did not get all the mention facts.

My previous guess was correct.

Parameter should be something like below according to PiPL grammar. (in Sample Pipl.r file)

'mymod', /* event ID, must be unique */

       NO_REPLY, /* never a reply */

            IMAGE_DIRECT_PARAMETER, /* direct parameter, used by Photoshop */ 

            {

            "action",    /* name for parameter*/

             keyMyPara,    /*Key parameter you have define in terminology file*/

             typeChar,       /*parameter type*/

             "",     /*optional description*/

             flagsSingleParameter     /*flags */

            }

The UUID is enough for calling plugin, only challenge was to define parameter wtr grammar at PiPL and read it at C++ end.

Another important fact is that we have the message pointer which points to above plug-in parameters.

Automation plugin would give that access.

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