Skip to main content
hong kiemp34358061
Participant
December 21, 2016
Answered

registrer action plug-in of illustrator

  • December 21, 2016
  • 1 reply
  • 1358 views

hi All!

i'm a newbie on illustrator, i read the Illustrator CS6 Programmer's Guide, at pages 27 - Action plug-ins introduce registering action plug-ins events with Tutorial example, but i don't see any Action events showed in action panel. so someone can help me. Thanks!

This topic has been closed for replies.
Correct answer A. Patterson

Actions only show in the panel after they've been recorded. You need to register your action and when your plugin is fired, check if recording is on (AIActionManagerSuite::InRecordMode). If so, you record your action using the AIActionManagerSuite. Then you just listen to the caller/selector that indicates AI wants you to play it back, and you unroll the parameters using the same suite and perform your operation.

1 reply

A. Patterson
A. PattersonCorrect answer
Inspiring
December 21, 2016

Actions only show in the panel after they've been recorded. You need to register your action and when your plugin is fired, check if recording is on (AIActionManagerSuite::InRecordMode). If so, you record your action using the AIActionManagerSuite. Then you just listen to the caller/selector that indicates AI wants you to play it back, and you unroll the parameters using the same suite and perform your operation.

hong kiemp34358061
Participant
December 22, 2016

thank you, A. Patterson! I did it as your guide, but not get any action. cause is in addAction function do not finish to register action event. you can give an example to me ? thanks so much

A. Patterson
Inspiring
December 22, 2016

During start up, you need register the action like so (rough code):

AIActionParamTypeRef actionParameters = 0;

AIErr error = sAIActionManager->AINewActionParamType(&actionParameters);

// add parameters using AIActionSetType

// register action with RegisterActionEvent & actionParameters

// clean up when done

sAIActionManager->AIDeleteActionParamType(actionParameters);

Next, when you are about to execute the functionality you described when you registered the action, you check to see if the user is recording:

if (sAIActionManager->InRecordMode()) {

     AIActionParamValueRef valueBlock;

     AIErr error = sAIActionManager->AINewActionParamValue(&valueBlock);

     // e.g.

     sAIActionManager->AIActionSetReal(valueBlock, 'valu', 10.0f);

     sAIActionManager->RecordActionEvent("my_action_name", kDialogOff, valueBlock);

     // clean up

     sAIActionManager->AIDeleteActionParamValue(valueBlock);

}

Now the action has been recorded. It should show up in the Action panel.

Lastly, when the user plays the action, you'll get a call/selector of kActionCaller / kDoActionSelector (see AIActionManager.h). When you get that, you need to cast the message void* to a DoActionMessage. It has a AIActionParamValueRef member param, from which you pull out the action values:

DoActionMessage* doActionMessage = reinterpret_cast<DoActionMessage*>(message);

AIReal value = 0.0f;

AIErr error = sAIActionManager->AIActionGetReal(message->param, id, &value);

// pull out other parameters if there are any

// do your functionality!

There are a bunch of other parameters with registering & recording actions you should play with. You can record enums, for example, which let you store a value like '10' with a string to describe it. You can also specify whether or not your functionality has a dialog or not, and let the action indicate if they want to show your dialog or not (they want to stop and tweak action parameters halfway through a playback).

Hope that helps!