7 Replies Latest reply on Jan 4, 2017 6:15 AM by A. Patterson

    registrer action plug-in of illustrator

    hong kiemp34358061

      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!

        • 1. Re: registrer action plug-in of illustrator
          A. Patterson Level 4

          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.

          • 2. Re: registrer action plug-in of illustrator
            hong kiemp34358061 Level 1

            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

            • 3. Re: registrer action plug-in of illustrator
              A. Patterson Level 4

              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!

              • 4. Re: registrer action plug-in of illustrator
                hong kiemp34358061 Level 1

                Thank you, A. Patterson! I have a problem not finished: I created a plugin named "Rename Art" showed on the Tool panel. when I click on it will rename all arts selected. this plugin has executed exactly. could I call it in vb.net script? if could, how do I have to do ? Thank you so much

                • 5. Re: registrer action plug-in of illustrator
                  A. Patterson Level 4

                  Not quite sure I'm understanding you, but I think you're asking if you can invoke a plugin from ExtendScript (or just scripting in general)?

                   

                  The answer is...sort of. AIScriptMessage.h has the C++ end of things, but I'm struggling to remember how you invoke that from script.

                   

                  I think it's like so:

                   

                  app.sendScriptMessage("exact_plugin_name", "function_name", "parameter1, parameter2, parameter3");
                  

                   

                  If you look at AIScriptMessage.h, it has sample code for catching the related caller and pulling out the information. It's pretty crappy, but it should work.

                  • 6. Re: registrer action plug-in of illustrator
                    hong kiemp34358061 Level 1

                    I mean: I created a plugin do anything (ex: rename all arts,...). After, I create a Tool using VB.net, this Tool will rename all objects in a file illustrator. In my Tool, can I use the plugin created before ? if can, how do i have to do ? Thank you so much!

                    • 7. Re: registrer action plug-in of illustrator
                      A. Patterson Level 4

                      I'm afraid I don't have any experience VB.net so I don't know what's possible there. Maybe someone else will have some experience that can shed some light on it. Good luck though!