c4d.plugins.CommandData¶
-
class
c4d.plugins.
CommandData
¶ - A data class for creating new commands.Use
RegisterCommandPlugin()
to register the plugin.See also
Py-CommandData_Dialog and Py-MemoryViewer plugin examples.
Methods Signatures
Override - Called when the plugin is selected by the user. |
|
Override - Called by Cinema 4D when loading a layout and restoring async dialogs.
|
|
Override - Called when the command receives messages. |
|
Override - Create dynamic subcontainer entries for a menu.
|
|
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. |
|
Override - Execute the command plugin with the subid that was given by |
|
Override - Execute the command plugin when the user calls it through its options dialog. |
|
Override - Called to get the state of the command.
|
Inheritance
Parent Class:
Methods Documentation
-
CommandData.
Execute
(self, doc)¶ Override - Called when the plugin is selected by the user.
- Parameters
doc (c4d.documents.BaseDocument) – The currently active document when the command was selected.
- Return type
bool
- Returns
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 is not implemented Cinema 4D will create an empty “???” dialog.
- Parameters
secret (PyCObject) – An internal hook. Pass it to
GeDialog.Restore()
- Return type
bool
- Returns
True if the dialog was restored, otherwise False.
-
CommandData.
Message
(self, type, data)¶ Override - Called when the command receives messages.
See also
C4DAtom and Plugin Messages for information on the messages type, data and input/output.
- Parameters
type (int) – The message type.
data (any) – The message data.
- Return type
bool
- Returns
Depends on the message type.
-
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 (c4d.documents.BaseDocument) – The currently active document when the command was selected.
submenu (c4d.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 (c4d.documents.BaseDocument) – The currently active document when the command was selected.
subid (int) – Sub command ID.
- Return type
bool
- Returns
True if the message was processed.
-
CommandData.
ExecuteOptionID
(self, doc, plugid, subid)¶ Override - Execute the command plugin when the user calls it through its options dialog.
Note
Plugins must be
registered
with PLUGINFLAG_COMMAND_OPTION_DIALOG set.- Parameters
doc (c4d.documents.BaseDocument) – The currently active document when the command was selected.
plugid (int) – The command’s plugin ID.
subid (int) – Only available for plugins that have sub-IDs (which normally are called using
ExecuteSubID()
).
- Return type
bool
- Returns
True if the command was executed successfully, otherwise False.
-
CommandData.
GetState
(self, doc)¶ - Override - Called to get the state of the command.This affects how it is displayed in menus or toolbars.
- Parameters
doc (c4d.documents.BaseDocument) – The document that is currently active in the editor.
- Return type
int
- Returns
A combination of the state flags:
Symbol ID
Description
CMD_ENABLED
Enabled.
CMD_VALUE
Checked.
CMD_HIDDEN
Hidden.