Skip to main content
Inspiring
October 11, 2011
Answered

Call a user action from a plugin

  • October 11, 2011
  • 3 replies
  • 1306 views

Hello

Is it possible to call an action made by a user, if yes how I can retrieve it (by its name ?) and is it possible to set some arguments of the action ?

Thanks

This topic has been closed for replies.
Correct answer Toto RoToTO

here it is a sample of how PlayActionEvent method could be used:

ASErr

AIArtHandleModifier::Rasterize()

{

          AIErr result = kNoErr;

          AIActionParamValueRef valueParameterBlock = NULL;

          ActionDialogStatus dialogStatus = kDialogOff

  try

          {

                    result = sAIActionManager->AINewActionParamValue(&valueParameterBlock);

                    aisdk::check_ai_error(result);

                    if (valueParameterBlock)

                    {

                              //set valueParameterBlock values (params) before calling

                              //PlayActionEvent method.

                              //It's up to you to set it

                              result = sAIActionManager->PlayActionEvent("ai_plugin_rasterize", dialogStatus, valueParameterBlock);

                              aisdk::check_ai_error(result);

                              result = sAIActionManager->AIDeleteActionParamValue(valueParameterBlock);

                              aisdk::check_ai_error(result);

                    }

               }

          catch(ai::Error& ex)

          {

           //Do something with this!!!

          }

  return result;

}

Regards,

Thomas.

3 replies

Rick E Johnson
Inspiring
December 15, 2022

I would like to do something similar, to play back a top-level action as recorded by the user, e.g., the Default Actions' "Rasterize (Selection)" which contains "ai_plugin_rasterize" and could be modified to contain other action items from other plugins as well. Another example is the "Delete Unused Panel Items" user action which contains multiple individual plugin actions. I will know in advance the name of the action I want to play, and wish to exit gracefully if an action by that name does not exist.

 

My dilemna is that user actions can play user scripts, user scripts can play user actions, but I want to play one or the other directly from my plugin. I suspect this simply is not possible, but must ask before giving up. -- Thanks

Toto RoToTO
Toto RoToTOCorrect answer
Inspiring
January 3, 2012

here it is a sample of how PlayActionEvent method could be used:

ASErr

AIArtHandleModifier::Rasterize()

{

          AIErr result = kNoErr;

          AIActionParamValueRef valueParameterBlock = NULL;

          ActionDialogStatus dialogStatus = kDialogOff

  try

          {

                    result = sAIActionManager->AINewActionParamValue(&valueParameterBlock);

                    aisdk::check_ai_error(result);

                    if (valueParameterBlock)

                    {

                              //set valueParameterBlock values (params) before calling

                              //PlayActionEvent method.

                              //It's up to you to set it

                              result = sAIActionManager->PlayActionEvent("ai_plugin_rasterize", dialogStatus, valueParameterBlock);

                              aisdk::check_ai_error(result);

                              result = sAIActionManager->AIDeleteActionParamValue(valueParameterBlock);

                              aisdk::check_ai_error(result);

                    }

               }

          catch(ai::Error& ex)

          {

           //Do something with this!!!

          }

  return result;

}

Regards,

Thomas.

nosleducAuthor
Inspiring
January 3, 2012

Thanks.

I succeeded to use the ai_plugin_rasterize.

I exported the action to see how to get the names and the values for the different parameters.

A. Patterson
Inspiring
October 12, 2011

I think its possible. You'd do it with AIActionManager::PlayActionEvent() (AIActionManager.h). It takes a AIActionParamValueRef which is made up of parameters, so yes, you can set parameters. I'm not sure how you figure out the name exactly though. Its probably whatever you name it when you record it, but I'm not sure if that's enough for the system to find it? Hopefully, but I've never tried so I don't know the details exactly. I've used it to run built-in Adobe actions though and I know that works just fine.