4 Replies Latest reply: Sep 16, 2013 12:32 AM by cincirin RSS

    Hot to call import plugin from automation plugin

    cincirin

        Hi,

       

      I was able to call filter plug-in from my automation plug-in. Now I'm stuck in calling import plug-in.

      I build GradientImport example from PhotoshopSDK, and modify resource PIPL to have unique string ID. ( i.e. I changed this line HasTerminology { plugInClassID, plugInEventID, ResourceID, "" } ) and put a unique ID.

      Then I tried to call it from my automation plug-in, but always I get this error: The command "AdobeSDK GradientImport" is not currently available.

       

      What should I change/modify for to be able to call import plug-in (GradientImport is ok) from my automation plug-in ?

       

      Thanks.

        • 1. Re: Hot to call import plugin from automation plugin
          Tom Ruark Adobe Employee

          What does script listener give you for your new string change?

          Make sure you right click on .r file and recompile then right click on .rc file and compile when making pipl changes on windows.

           

          Here is how to call the unmodified version of GradientImport.

           

          // =======================================================

          var idImpr = charIDToTypeID( "Impr" );

              var desc1 = new ActionDescriptor();

              var idUsng = charIDToTypeID( "Usng" );

                  var desc2 = new ActionDescriptor();

                  var idmulK = charIDToTypeID( "mulK" );

                      var list1 = new ActionList();

                          var desc3 = new ActionDescriptor();

                          var idVrtc = charIDToTypeID( "Vrtc" );

                          var idshPxl = charIDToTypeID( "#Pxl" );

                          desc3.putUnitDouble( idVrtc, idshPxl, 256.000000 );

                          var idHrzn = charIDToTypeID( "Hrzn" );

                          var idshPxl = charIDToTypeID( "#Pxl" );

                          desc3.putUnitDouble( idHrzn, idshPxl, 256.000000 );

                          var idMdspsp = charIDToTypeID( "Md  " );

                          var idgrmT = charIDToTypeID( "grmT" );

                          var idrgbC = charIDToTypeID( "rgbC" );

                          desc3.putEnumerated( idMdspsp, idgrmT, idrgbC );

                      var idmulS = charIDToTypeID( "mulS" );

                      list1.putObject( idmulS, desc3 );

                  desc2.putList( idmulK, list1 );

              var idgraD = charIDToTypeID( "graD" );

              desc1.putObject( idUsng, idgraD, desc2 );

          executeAction( idImpr, desc1, DialogModes.NO );

          • 2. Re: Hot to call import plugin from automation plugin
            cincirin Community Member

            Hi Tom,

             

            Thank you very much for your interest.

            I reverted all GradientImport changes. Now I have what you have :-)

             

            This is my C++ source code (based on your example, I guess from listener) to call GradientImport from my automation plug-in:

             


            DescriptorTypeID imprID = 0;

            m_actionControlProcs->StringIDToTypeID("Impr", &imprID);

            DescriptorTypeID usngID = 0;

            m_actionControlProcs->StringIDToTypeID("Usng", &usngID);

            DescriptorTypeID mulkID = 0;

            m_actionControlProcs->StringIDToTypeID("mulK", &mulkID);

            DescriptorTypeID gradID = 0;

            m_actionControlProcs->StringIDToTypeID("graD", &gradID);

            DescriptorTypeID mulsID = 0;

            m_actionControlProcs->StringIDToTypeID("mulS", &mulsID);

             


            PIActionDescriptor desc3 = NULL;

            m_actionDescriptorProcs->Make(&desc3);

            m_actionDescriptorProcs->PutUnitFloat(desc3, keyHorizontal, unitPixels, 256.0);

            m_actionDescriptorProcs->PutUnitFloat(desc3, keyVertical, unitPixels, 256.0);

             


            PIActionList actionList = NULL;

            m_actionListProcs->Make(&actionList);

            m_actionListProcs->PutObject(actionList, mulsID, desc3);

             


            PIActionDescriptor desc2 = NULL;

            m_actionDescriptorProcs->Make(&desc2);

            m_actionDescriptorProcs->PutList(desc2, mulkID, actionList);

             

             


            PIActionDescriptor desc1 = NULL;

            m_actionDescriptorProcs->Make(&desc1);

            m_actionDescriptorProcs->PutObject(desc1, usngID, gradID, desc2);

             


            PIActionDescriptor output = NULL;

            bool play = kSPNoError == m_actionControlProcs->Play(&output, imprID, desc1, plugInDialogDisplay);

             

             

            ... and header file of my class :


            PSActionControlProcs* m_actionControlProcs;

            PSActionDescriptorProcs* m_actionDescriptorProcs;

            PSActionReferenceProcs* m_actionReferenceProcs;

            PSActionListProcs* m_actionListProcs;

             

            Now everytime I got the following error:

            "The command <unknown> is not currently available"

             

            I think this means imprID event is not available. Also note that I can manually open GradienImport import plug-in from File/Import menu.

             

            Thank you.

            • 3. Re: Hot to call import plugin from automation plugin
              Tom Ruark Adobe Employee

              You don't need the stringid to typeid calls. GradientImport is using four character codes and you can use them directly. Here is a C++ version that should work for you. Did the JavaScript version work for you? I got this output from Listener.log.

               

              SPErr PlayeventImport(/*your parameters go here*/void)

              {

                   PIActionDescriptor result = NULL;

                   DescriptorTypeID runtimeKeyID;

                   DescriptorTypeID runtimeTypeID;

                   DescriptorTypeID runtimeObjID;

                   DescriptorTypeID runtimeEnumID;

                   DescriptorTypeID runtimeClassID;

                   DescriptorTypeID runtimePropID;

                   DescriptorTypeID runtimeUnitID;

                   SPErr error = kSPNoError;

                   // Move this to the top of the routine!

                   PIActionDescriptor desc00000190 = NULL;

               

               

                   error = sPSActionDescriptor->Make(&desc00000190);

                   if (error) goto returnError;

               

               

                        // Move this to the top of the routine!

                        PIActionDescriptor desc00000198 = NULL;

               

               

                        error = sPSActionDescriptor->Make(&desc00000198);

                        if (error) goto returnError;

               

               

                             // Move this to the top of the routine!

                             PIActionList list00000028 = NULL;

                             error = sPSActionList->Make(&list00000028);

                             if (error) goto returnError;

               

               

                                  // Move this to the top of the routine!

                                  PIActionDescriptor desc000001A0 = NULL;

               

               

                                  error = sPSActionDescriptor->Make(&desc000001A0);

                                  if (error) goto returnError;

               

               

                                  error = sPSActionDescriptor->PutUnitFloat(desc000001A0, keyVertical, unitPixels, 256);

                                  if (error) goto returnError;

               

               

                                  error = sPSActionDescriptor->PutUnitFloat(desc000001A0, keyHorizontal, unitPixels, 256);

                                  if (error) goto returnError;

               

               

                                  error = sPSActionDescriptor->PutEnumerated(desc000001A0, keyMode, 'grmT', 'rgbC');

                                  if (error) goto returnError;

               

               

                             error = sPSActionList->PutObject(list00000028, 'mulS', desc000001A0);

                             if (error) goto returnError;

               

               

                        error = sPSActionDescriptor->PutList(desc00000198, 'mulK', list00000028);

                        if (error) goto returnError;

               

               

                   error = sPSActionDescriptor->PutObject(desc00000190, keyUsing, 'graD', desc00000198);

                   if (error) goto returnError;

               

               

                   error = sPSActionControl->Play(&result, eventImport, desc00000190, plugInDialogSilent);

                   if (error) goto returnError;

               

               

              returnError:

                   if (result != NULL) sPSActionDescriptor->Free(result);

                   if (desc00000190 != NULL) sPSActionDescriptor->Free(desc00000190);

                   if (desc00000198 != NULL) sPSActionDescriptor->Free(desc00000198);

                   if (list00000028 != NULL) sPSActionList->Free(list00000028);

                   if (desc000001a0 != NULL) sPSActionDescriptor->Free(desc000001a0);

                   return error;

              }

              • 4. Re: Hot to call import plugin from automation plugin
                cincirin Community Member

                Hi Tom,

                 

                Thanks, your listener log was correct. Mine listener crashed all the time, I fixed it, but listener.log was created with errors.

                Anyway, thanks again. I was confused because for start filter plug-in need to pass unique id in Play function, and for import plug-in need to pass eventImport