Command Modules


Command Modules are by far the simplest type of module in messiah. The easiest way to describe Command Modules is to have you take a look at messiah's Customize->Key Command Manager module. This is where users can create new Command Modules of their own, and assign Command Modules to hot keys. You can see here that Command Modules consist of a name, a classification and a command string. The name is simple enough, this just identifies the Command Module. The classification allows Command Modules to be grouped by the actions they perform (see the list below and to the left in the KeyCommand Manager block). The command string is just a string that will be treated as though it had been typed into messiah's command port when it gets executed. This command string is any valid expression and may be as complex as you like. If the command string would work as an expression in Command mode, it will work as a command string.
For example consider the built in Command Module "MetaNURBS On/Off" (found under the Object class). The command string for this command is: "MNURBSToggle(CurObj())". Both MNURBSToggle and CurObj are Function Modules that are typically used in expressions and scripts. By default this command is assigned to the Tab key, therefore whenever the user presses the Tab key it will be as though they had typed "MNURBSToggle(CurObj())" into the command port and hit Enter.
There are other ways that a Command Module can be executed aside from key assignment. You can type a command name into the command port and it will be executed when you hit Enter (or the E button). You may also call Command Modules through the API using the fxCommandExecute() function, passing it either the command ID or the name of the command. This also allows you to use Command Modules created in other plugins, and allow other plugins to use your Command Modules.
Registering Commands
Creating a new Command Module through the API is no more complicated than doing it though messiah's interface. Keep in mind however that as simple as Command Modules are, they are still Modules and must be registered in your messiahEntry() function.
We use the fxCommandRegister() function to register a Command Module; passing it a name, command class and command string. It will return to us an FXcommand ID which we can use later to execute the Command Module with fxCommandExecute() (Note: it is more efficent to execute a Command Module using it's ID rather than its name, since no string comparison is needed for an ID.) Taking our MetaNURBS example from above, we could duplicate this Command Module ourselves with the following:

FXcommand mnurbCmd = FX_NULLID;

mnurbCmd = fxCommandRegister( "MetaNURBS On/Off", FX_COMCLASS_GENERAL, "MNURBSToggle(CurObj())", FX_NOFLAG );
Now we can execute that Command Module by key assignment, typing "MetaNURBS On/Off" (minus the quotes) or by caling fxCommandExecute() like so:

fxCommandExecute( mnurbCmd, NULL, FX_NOFLAG );
See Tutorial - HelloCmd for an example Command Module.


© 2003 pmG WorldWide, LLC.


www.projectmessiah.com

groups.yahoo.com/pmGmessiah

Last Updated on Thu Jul 10 04:49:36 2003