Command Utility Manual

About

A lot of functionality of Cinema 4D is implemented in form of commands. Such commands are plugins based on CommandData. A command is identified by a specific ID that can be used to invoke that command.

Note
The described functions can only be used from the main thread, see Cinema 4D Threads Manual.
The command IDs can easily be obtained from the "Customize Commands" dialog.
These functions wrap around SendCoreMessage().
For modeling commands see SendModelingCommand(), for UV commands see CallUVCommand(), for painter commands see SendPainterCommand().

Functionality

These functions exist to access and utilize existing Cinema 4D commands:

// This example prints the name and help text of the given command.
const Int32 commandID = 12098; // save active project
const maxon::String name = GetCommandName(commandID);
const maxon::String help = GetCommandHelp(commandID);
ApplicationOutput("Command \"@\" (@)"_s, name, help);
const char const char * name
Definition: abstract.h:195
String GetCommandName(Int32 id)
String GetCommandHelp(Int32 id)
Definition: string.h:1237
maxon::Int32 Int32
Definition: ge_sys_math.h:56
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:204
Warning
Using CallCommand() is the same as pressing the corresponding button in the GUI. This means the command operates on the active document, adds undo-steps and sends messages. So CallCommand() should only be used in response to some user interaction e.g. when a button in a GeDialog was pressed.
// This example checks if the given command is enabled.
// If so it is executed.
const Int32 commandID = 14047; // subdivide command
// check if the command is enabled (available)
if (IsCommandEnabled(commandID))
{
CallCommand(commandID);
}
Bool IsCommandEnabled(Int32 id)
void CallCommand(Int32 id, Int32 subid=0)

Further Reading