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.ToolData

A data class for creating tool plugins. Use RegisterToolPlugin() to register the plugin.

class c4d.plugins.ToolData

//Methods to override

SuperClass

BaseData

Methods

ToolData.InitTool(self, doc, data, bt)

Override - Called each time the tool is selected.

Parameters:
  • doc (BaseDocument) – The active document.
  • data (BaseContainer) – The original tool settings container.
  • bt (None) – Currently not used.
Return type:

bool

Returns:

True if there was no error, otherwise False.

ToolData.FreeTool(self, doc, data)

Override - Called each time the user chooses another tool.

Parameters:
Return type:

bool

Returns:

True if there was no error, otherwise False.

ToolData.InitDefaultSettings(self, doc, data)

Called to let you intialize the default tool settings in data.

Parameters:
ToolData.MouseInput(self, doc, data, bd, win, msg)

Override - Called when the user clicks with the mouse in any of the editors views.

Parameters:
  • doc (BaseDocument) – The currently active document.
  • data (BaseContainer) – The tool settings container.
  • bd (BaseDraw) – The BaseDraw object for the active editor view.
  • win (EditorWindow) – The EditorWindow object for the active editor view.
  • msg (BaseContainer) – The original message container.
Return type:

bool

Returns:

False if a problem occured during this function.

ToolData.KeyboardInput(self, doc, data, bd, win, msg)

Override - Called when the user types something in any of the editors views.

Note

Make sure that you only use this function when the user is somehow working with your plugin, so that other plugins can also use this hook when it’s their turn.

Parameters:
  • doc (BaseDocument) – The currently active document.
  • data (BaseContainer) – The tool settings container.
  • bd (BaseDraw) – The BaseDraw object for the active editor view.
  • win (EditorWindow.) – The EditorWindow object for the active editor view.
  • msg (BaseContainer.) – The original message container.
Return type:

bool

Returns:

False if a problem occured during this function.

ToolData.GetState(self, doc)

Called to check if the tool should be enabled, checked or not.

Parameter:

doc (BaseDocument) – The document the tool is being used in.

Return type:

int

Returns:

The return flags are stored in c4d.gui:

CMD_ENABLED

Enabled.

CMD_VALUE

Checked.

ToolData.GetCursorInfo(self, doc, data, bd, x, y, bc)

Called when the cursor is over editor window to get the state of the mouse pointer. You can set the bubble help and cursor using for example:

bc.SetString(RESULT_BUBBLEHELP, "My Tools Help");
bc.SetLong(RESULT_CURSOR, MOUSE_POINT_HAND);
Parameters:
  • doc (BaseDocument) – The currently active document.
  • data (BaseContainer.) – The tool settings container.
  • bd (BaseDraw) – The BaseDraw object for the active editor view.
  • x (float) – The x coordinate of the mouse cursor relative to the top-left of the currently active editor view.
  • y (float) – The y coordinate of the mouse cursor relative to the top-left of the currently active editor view.
  • bc (BaseContainer) –

    The container to store the result in. Use the following container IDs, stored in c4d.gui:

    RESULT_BUBBLEHELP str Bubbletext help.
    RESULT_CURSOR int Cursortype.
    MOUSE_HIDE Hide cursor.
    MOUSE_SHOW Show cursor.
    MOUSE_NORMAL Normal cursor.
    MOUSE_BUSY Busy cursor.
    MOUSE_CROSS Cross cursor.
    MOUSE_QUESTION Question cursor
    MOUSE_ZOOM_IN Zoom in cursor.
    MOUSE_ZOOM_OUT Zoom out cursor.
    MOUSE_FORBIDDEN Forbidden cursor.
    MOUSE_DELETE Delete cursor.
    MOUSE_COPY Copy cursor.
    MOUSE_INSERTCOPY Insert copy cursor.
    MOUSE_INSERTCOPYDOWN Insert copy down cursor.
    MOUSE_MOVE Move cursor.
    MOUSE_INSERTMOVE Insert move cursor.
    MOUSE_INSERTMOVEDOWN Insert move cursor.
    MOUSE_ARROW_H Horizontal cursor.
    MOUSE_ARROW_V Vertical cursor.
    MOUSE_ARROW_HV Horizontal and vertical arrow cursor.
    MOUSE_POINT_HAND Point hand cursor.
    MOUSE_MOVE_HAND Move hand cursor.
    MOUSE_IBEAM I-beam cursor.
    MOUSE_SELECT_LIVE Live selection cursor.
    MOUSE_SELECT_FREE Free selection cursor.
    MOUSE_SELECT_RECT Rectangle selection cursor.
    MOUSE_SELECT_POLY Polygon selection cursor.
    MOUSE_SPLINETOOLS Spline tools cursor.
    MOUSE_EXTRUDE Extrude cursor.
    MOUSE_NORMALMOVE Normal move cursor.
    MOUSE_ADDPOINTS Add points cursor.
    MOUSE_ADDPOLYGONS Add polygons cursor.
    MOUSE_BRIDGE Bridge cursor.
    MOUSE_MIRROR Mirror cursor.
    MOUSE_PAINTMOVE Paint move cursor.
    MOUSE_PAINTSELECTRECT Paint select rectangle cursor.
    MOUSE_PAINTSELECTCIRCLE Paint select circle cursor.
    MOUSE_PAINTSELECTPOLY Paint select polygon cursor.
    MOUSE_PAINTSELECTFREE Paint select free cursor.
    MOUSE_PAINTMAGICWAND Paint magic wand cursor.
    MOUSE_PAINTCOLORRANGE Paint color range cursor.
    MOUSE_PAINTFILL Paint fill cursor.
    MOUSE_PAINTPICK Paint pick cursor.
    MOUSE_PAINTBRUSH Paint brush cursor.
    MOUSE_PAINTCLONE Paint clone cursor.
    MOUSE_PAINTTEXT Paint text cursor.
    MOUSE_PAINTCROP Paint crop cursor.
    MOUSE_PAINTLINE Paint line cursor.
    MOUSE_PAINTPOLYSHAPE Paint polygon shape cursor.
Return type:

bool

Returns:

False if a problem occured during this function.

ToolData.Draw(self, doc, data, bd, bh, bt, flags)

Called when the editor view is updated so you can display graphics for your tool in the view.

Parameters:
  • doc (BaseDocument) – The active document.
  • data (class:BaseContainer <c4d.BaseContainer>) – The tool settings container.
  • bd (BaseDraw) – The BaseDraw object for the active editor view.
  • bh (PyCObject) – Private - internal helper
  • flags (int) –

    Some fags.

    DRAWFLAGS_INVERSE_Z This flag is used for inverse Z-buffer use, with this mode the drawing engine of CINEMA will only draw elements if they are further away from the camera than other objects. This is mostly used for helplines (such as the semitransparent axis inside of objects). This mode only works when all objects are drawn so it should be the passed last.
    DRAWFLAGS_HIGHLIGHT Highlight mode.
  • bt (None) – Currently not used
Return type:

int

Returns:

The values for this are stored in c4d:

DRAW_HANDLES

The active objects handles will be drawn.

DRAW_AXIS

The active objects axes will be drawn.

DRAW_HIGHLIGHTS

The highlights will be drawn.

DRAW_ALPHA_NONE

No alpha.

DRAW_ALPHA_INVERTED

Inverted alpha.

DRAW_ALPHA_NORMAL

Normal alpha.

DRAW_GET_VIEWMATRIX_PROJECTION

Projection.

DRAW_GET_VIEWMATRIX_PROJECTION_LARGE_Z

Large Z.

DRAW_GET_VIEWMATRIX_INV_CAMERA

Inverse camera.

DRAW_PARAMETER_LINEWIDTH

Line width in pixels. (OpenGL only.)

DRAW_PARAMETER_ALPHA_THRESHOLD

Alpha treshold. (Make sure to set old value back afterwards!)

LONG DRAW_PARAMETER_SETZ

Z buffer mode:

DRAW_Z_LOWEREQUAL

Normal mode.

DRAW_Z_GREATER

Reversed mode.

DRAW_Z_ALWAYS

Always mode.

DRAW_PARAMETER_OGL_CULLING_OFF

 

DRAW_PARAMETER_OGL_CULLING_FRONT

 

DRAW_PARAMETER_OGL_CULLING_BACK

 

DRAW_PARAMETER_OGL_CULLING_FRONT_AND_BACK

 

LONG DRAW_PARAMETER_OGL_CULLING

OpenGL culling:

DRAW_PARAMETER_USE_Z

Use Z.

DRAW_Z_LOWEREQUAL

Normal mode.

DRAW_Z_GREATER

Reversed mode.

DRAW_Z_ALWAYS

Always mode.

ToolData.AllocSubDialog(self, bc)

Called to get a GUI for the Active Tool window. Return an instance of your tool’s dialog.

Parameter:bc (BaseContainer) – Currently not used.
Return type:SubDialog
Returns:The allocated sub dialog.
ToolData.Message(self, doc, data, type)

Called to get a GUI for the Active Tool window. Return an instance of your tool’s dialog.

Parameters:
  • doc (BaseContainer) – The current document.
  • data (int) – The message ID.
  • type (int) –

    The message ID, one of the following, stored in c4d:

    MSG_POINTS_CHANGED  
    MSG_POLYGONS_CHANGED  
    MSG_SEGMENTS_CHANGED  
    MSG_UPDATE  
    MSG_SMALLUPDATE Part of the object has changed that needs no cache rebuilding.
    MSG_CHANGE Must be sent if any object data (except for the matrix) has been changed.
    MSG_BASECONTAINER  
    MSG_FILTER  
    MSG_TRANSFERGOALS Internal message.
    MSG_DESCRIPTION_INITUNDO  
    MSG_DESCRIPTION_CHECKUPDATE  
    MSG_DESCRIPTION_COMMAND  
    MSG_DESCRIPTION_POPUP  
    MSG_DESCRIPTION_POSTSETPARAMETER  
    MSG_DESCRIPTION_VALIDATE  
    MSG_EDIT Allows elements to do some action if the user edits the element (doubleclick e.g. in object manager).
    MSG_MENUPREPARE  
    MSG_RETRIEVEPRIVATEDATA  
    MSG_DESCRIPTION_REMOVE_ENTRY  
    MSG_DESCRIPTION_EDIT_ENTRY  
    MSG_DESCRIPTION_CHECKDRAGANDDROP  
    MSG_DESCRIPTION_GETBITMAP  
    MSG_DESCRIPTION_GETOBJECTS Private.
    MSG_DESCRIPTION_USERINTERACTION_END End of user interaction.
    MSG_DESCRIPTION_GETINLINEOBJECT  
    MSG_GETCUSTOMICON  
    MSG_MATERIALDRAGANDDROP  
    MSG_INITIALCHANNEL  
    MSG_DOCUMENTINFO  
    MSG_GETSELECTION Private.
    MSG_MULTI_DOCUMENTCLONED The document has been cloned.
    MSG_MULTI_DOCUMENTIMPORTED  
    MSG_MULTI_MARKMATERIALS  
    MSG_MULTI_RENDERNOTIFICATION  
    MSG_TRANSLATE_POINTS  
    MSG_TRANSLATE_POLYGONS  
    MSG_TRANSLATE_NGONS  
    MSG_TRANSLATE_SEGMENTS  
    MSG_PRETRANSLATE_POINTS  
    MSG_PRETRANSLATE_POLYGONS  
    MSG_PRETRANSLATE_NGONS  
    MSG_PRETRANSLATE_SEGMENTS  
    MSG_UPDATE_NGONS Should be sent if points are changed and any N-gons need updating. CINEMA 4D will then update the N-gons, if the user has this option enabled.
    MSG_DOCUMENT_MODE_CHANGED  
    MSG_TOOL_RESTART Private. (Handles the tool description apply behaviour after mouse clicks.)
    MSG_MOVE_FINISHED Sent after a handle or the object has been moved.
    MSG_DEFORMMODECHANGED Private.
    MSG_ANIMATE Sent to objects after they have been animated.
    MSG_GET_MODATASELECTION  
    MSG_MOVE_START Sent before a handle or the object has been moved.
    MSG_EDITABLE_END Private.
    MSG_DRAGANDDROP Received when something is dropped on it. The corresponding data is DragAndDrop.
    MSG_MULTI_SETNEWMARKERS Private.
    MSG_MULTI_CLEARSUGGESTEDFOLDER  
    MSG_CALCMEMUSAGE Private.
Return type:

bool

Returns:

The value depends on the message type.

Table Of Contents

This Page