Hot Door CORE Forum
recording and playing back Actions - Printable Version

+- Hot Door CORE Forum (http://hotdoorcore.com/forum)
+-- Forum: All forums (http://hotdoorcore.com/forum/forumdisplay.php?fid=1)
+--- Forum: General discussion (http://hotdoorcore.com/forum/forumdisplay.php?fid=3)
+--- Thread: recording and playing back Actions (/showthread.php?tid=79)



recording and playing back Actions - Rick Johnson - 06-22-2016

Some of the plugins I wrote with the Adobe SDK were "actionable" in that users could record and play back Actions using them. I see a small CORE class ActionMessage, but I have a feeling it's unrelated. As I rewrite my plugins with CORE, can they be made Actionable again without adding Adobe SDK suites?


RE: recording and playing back Actions - garrett - 06-22-2016

You will likely need to include the Illustrator SDK headers for this, as CORE does not (currently) automate any handling of Illustrator "actions".


RE: recording and playing back Actions - Rick Johnson - 07-11-2020

I'm having some trouble reading the ActionGoMessageType message, hid::core::ActionMessage.

Here's a snippet from the GoAction callback from my Concatenate plugin from pre-CC days, pre-CORE, written with the SDK:

Code:
AIErr doAction( DoActionMessage *message ){
AIErr error = kNoErr;
AIActionParamValueRef valueParameterBlock = message->param;
long mode = 0;
error = sActionManager->AIActionGetInteger(valueParameterBlock, 'mode', &mode);

This code worked "back in the day" as they say. Now in CORE I'm subscribed to the dispatcher ActionGoMessageType. Here's a snippet from my CORE counterpart in the ActionGo callback:

Code:
hdi::core::Message* msg = this->__corePlug->dispatcher()->lastMessage();
DoActionMessage* message = reinterpret_cast<DoActionMessage*>(msg);
AIActionParamValueRef valueParameterBlock = message->param;
AIErr error = kNoErr;
long mode = 0;
error = sAIAction->AIActionGetInteger(valueParameterBlock, 'mode', &mode);

When I run this by playing the Action in AI, it crashes on AIActionGetInteger, or any function to retrieve a value from valueParameterBlock with "Thread 1: EXC_BAD_ACCESS (code=EXC_I386_GPFLT)" after a trip to hdi::aip:Big Grinispatcher::message.

Debugging in Xcode 10, I added a string item with the value "TEST" hoping I could see it when I viewed the memory of valueParameterBlock, but no luck. I also tried casting msg with "message = (DoActionMessage*)msg;" and also as an AIActionParamValueRef but it made no difference.

I believe the values it's trying to read were set correctly. I registered the action event, and while running Illustrator it recorded normally. All fields appeared in Illustrator's Actions panel with proper keys and values. Is there a better way to cast the message from lastMessage? Is there a simple way to get the DoActionMessage directly through the SDK after notification from CORE's dispatcher?

Any suggestions would be very much appreciated! If I get this working, I'll post a summary of all of the steps to share with others.


RE: recording and playing back Actions - Rick Johnson - 11-27-2022

Thank you for adding more support for raw data in messages with ->rawData() in CORE 0.8.1. I'm having trouble with the Play Action callback. Here's how it now attempts to get the Action Value Parameter Block, in response to an ActionGoMessageType message:

Code:
Void grody::Plugin::__actionGoCB(){
hdi::core::Message* msg = this->__corePlug->dispatcher()->lastMessage();
void* actionMsg = msg->rawData();
DoActionMessage* message = reinterpret_cast<DoActionMessage*>(actionMsg);
AIActionParamValueRef valueParameterBlock = message->param;

What I end up with, however is not a valid Action Value Parameter Block that I can read. I can record actions and see them in the Actions panel, so I'm sure the correct values are in there somewhere.

In the SDK samples, the main message handler simply re-casts it like this:


Code:
error = GoAction((DoActionMessage *)message);


so I also tried this:

Code:
DoActionMessage* message = (DoActionMessage*) this->__corePlug->dispatcher()->lastMessage()->rawData();

Any help would be very much appreciated.


RE: recording and playing back Actions - garrett - 11-29-2022

Have you verified with the SDK directly (i.e. without hdi_core) that the data is as you expect?

Our internal message handler literally takes the pointer to the data that Illustrator provides us, stores it for later retrieval, and gives you that same pointer when you call Message::rawData().


RE: recording and playing back Actions - Rick Johnson - 12-07-2022

I found the problem. I was recording an action where I added a string value like this:

error = sAIAction->AIActionSetString(valueParameterBlock, 'test', "TEST");

Although the actions appears to record into the Actions panel OK, the message passed back on playback was garbled before being recast.

Now in the ActionGo callback, I start with this:

DoActionMessage* message = (DoActionMessage*) this->__corePlug->dispatcher()->lastMessage()->rawData();
AIActionParamValueRef valueParameterBlock = message->param;

Everything now works great. I can explain more how I added Actions to my CORE project, but it's pretty much outlined in the SDK's Tutorial sample.

Another odd thing to watch for is that even if you RecordActionEvent with kDialogNone, message->showDialog may be true!