This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com

c4d.plugins.CommandData

A data class for creating new commands. Use RegisterCommandPlugin to register the plugin.

../../../../_images/main1.png
class c4d.plugins.CommandData

//Methods to override

SuperClass

BaseData

Methods

CommandData.Execute(self, doc)

Override - Called when the plugin is selected by the user.

Parameter:doc (BaseDocument) – The currently active document when the command was selected.
Return type:bool
Returns:Return True if the command was executed successfully, otherwise False.
CommandData.RestoreLayout(self, secret)

Override - Called by CINEMA 4D when loading a layout and restoring async dialogs. If this function isn’t implemented CINEMA will create an empty “???” dialog.

Parameter:secret (PyCObject.) – An internal hook. Pass it to Restore
Return type:bool
Returns:True if the dialog was restored, otherwise False.
CommandData.Message(self, type, data)

Override - Called for messages.

Parameter:id (int) – Message type
Return type:bool
Returns:Return True if the message was processed.
CommandData.GetSubContainer(self, doc, submenu)

Override - Create dynamic subcontainer entries for a menu. The menu entries on the top level will all be placed at the point where the command plugin was placed. To create a submenu, place the entries as subcontainers in the returned container with ID 0. In the subcontainer, place a string with ID 1 to name it:

bc = BaseContainer()
bc.SetString(1, "Submenu Test")
bc.SetString(1000, "First Entry")
submenu.InsData(0, bc)
Parameters:
  • doc (BaseDocument) – The currently active document when the command was selected.
  • submenu (BaseContainer) – Fill this with the submenu structure.
Return type:

bool

Returns:

True if you put anything in the container, otherwise False.

CommandData.GetScriptName(self)

Override - Return the script name of the command data. If this function is implemented, the command is stored by name rather than by ID in layouts, shortcuts and menus.

Return type:str
Returns:Script name.
CommandData.ExecuteSubID(self, doc, subid)

Override - Execute the command plugin with the subid that was given by GetSubContainer.

Parameters:
  • doc (BaseDocument) – The currently active document when the command was selected.
  • subid (int) – Sub command ID.
Return type:

bool

Returns:

Return True if the message was processed.

Table Of Contents

This Page