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
A dialog is a window or a panel, in which buttons, edit boxes, icons, images, and other things are put upon. These buttons, sliders, icons, etc are called widgets. Dialogs act as interfaces for a plugin. You are able to customize or derive a dialog box that will act as an interface for your plugin. Most dialog boxes are derived off of GeDialog class.
The reason you care about dialogs is that you want anyone to be able to use your plugin, and you want it to be easier to use. Plus it is a lot cooler when you have tons of widgets to play with. There is no other (easy) interactive way for you to interface with the user than with a dialog.
The class to create custom dialogs.
//Methods to override
//Basic methods
//Input events
// Setter
// Getter
Still private
Override - Called when C4D is about to display the dialog.
| Return type: | bool |
|---|---|
| Returns: | True if successful, or False to signalize an error. |
Override - Use to react to more messages..
| Parameters: |
|
|---|---|
| Return type: | int |
| Returns: | The return value depends on the message. |
Called when the dialog is initialized by the GUI.
| Return type: | bool |
|---|---|
| Returns: | True if successful, or False to signalize an error. |
Override this function if you want to react to C4D core messages. The original message is stored in msg.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | Currently not used - but you have to return a bool value. |
If the user wants to close the dialog with the OK button this function will be called. Override it to avoid closing the dialog if an error situation has occured. If you return False everything will be as usual, but if you return True the dialog won’t close. T
Warning
Please pay attention to the result value. True means, it will not close.
| Return type: | bool |
|---|---|
| Returns: | True if the dialog shouldn’t be closed, False if it should. |
If you subscribe to timer events using SetTimer(x), this function is called every x’th millisecond.
| Parameter: | msg (BaseContainer) – The raw timer message. |
|---|
Opens a dialog.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if successfully opened, otherwise False. |
Used to restore an asynchronous dialog that has been placed in the users layout. Just use this method in CommandData.RestoreLayout().
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if successfully restored, otherwise False. |
Polls a certain channel of a device for the current input state.
| Parameter: | askdevice (The channel of the device.) – The device to ask. |
|---|---|
| Return type: | BaseContainer |
| Returns: | The result is this container or None. |
Gets the next input event for a certain device from the event queue.
| Parameter: | askdevice (int) – The device to poll. |
|---|---|
| Return type: | BaseContainer |
| Returns: | The result is this container or None. |
Transforms local coordinates (relative to the top left corner of the dialog) to global coordinates (relative to the top left corner of the physical window). Result is a dict with member keys x and y of type int.
| Return type: | dict |
|---|---|
| Returns: | The converted coordinates or None. |
Transforms global coordinates (relative to the top left corner of the physical window) to local coordinates (relative to the top left corner of the dialog). Result is a dict with member keys x and y of type int.
| Return type: | dict |
|---|---|
| Returns: | The converted coordinates or None. |
Transforms local coordinates (relative to the top left corner of the dialog) to screen coordinates (relative to the top left corner of the system screen). Result is a dict with member keys x and y of type int.
| Return type: | dict |
|---|---|
| Returns: | The converted coordinates or None. |
Transforms screen coordinates (relative to the top left corner of the system screen) to local coordinates (relative to the top left corner of the dialog). Result is a dict with member keys x and y of type int.
| Return type: | dict |
|---|---|
| Returns: | The converted coordinates or None. |
Set The default color for GUI elements.
| Parameters: |
|
|---|
Gets the RGB values associated with a color code.
| Parameter: | colorid (int) – The color value.
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | dict | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns: | The color in the dict with the keys x, y and z. |
Close the dialog.
| Return type: | bool |
|---|---|
| Returns: | True if everything was fine, or False if any field is wrong. |
Add a checkbox to the dialog.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Add a button to the dialog.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a static text field to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds an editable text field to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds an editable text field with multiple lines to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds an editable number field to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds an editable number field with up/down arrows to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a slider with an editable number field to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a slider with an editable number field to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a simple color field without sliders to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a simple color field without sliders to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a simple color field without sliders to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a horizontal separator to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a vertical separator to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds a vertical separator to the layout.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Adds items to combo boxes or popup buttons. The resource equivalent is CHILDS.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the child was added. |
Clears the item list of combo boxes and popup buttons.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | bool |
| Returns: | True if the children were removed. |
Assigns a GeUserArea object to a user area control in the dialog. The object will handle all messages to the user area and is responsible for painting the user area. A good practice is to place the GeUserArea derived object as a member of the GeDialog derived class.
| Parameters: |
|
||||||||
|---|---|---|---|---|---|---|---|---|---|
| Return type: | bool |
||||||||
| Returns: | True if the children were removed. |
Adds a user area to the layout. Use GeDialog.AttachUserArea() to assign a GeUserArea object to the user area control.
| Parameters: |
|
||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | |||||||||||||||||||||||||||||
| Returns: | The added gadget. |
Begins a scrollgroup.
| Parameters: |
|
||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Return type: | bool |
||||||||||||||||||||||||||||||||||||||||||||||||||
| Returns: | True if scrollgroup was added. |
Notifies C4D that the layout of a dynamic group in the dialog has changed. This is usually done by first calling GeDialog.LayoutFlushGroup() and then adding new controls.
| Parameter: | id (int) – The ID of the changed group. |
|---|---|
| Return type: | bool |
| Returns: | True if the layout was updated, otherwise False. |
Notifies C4D that the layout of a dynamic group in the dialog has changed. This is usually done by first calling GeDialog.LayoutFlushGroup() and then adding new controls.
| Parameter: | id (C4DGadget or int) – The ID of the changed group. |
|---|---|
| Return type: | bool |
| Returns: | True if the layout was updated, otherwise False. |
Sets the focus to a specific control within the dialog.
| Parameter: | id (int) – The control ID |
|---|---|
| Return type: | bool |
| Returns: | True if the control was activated. |
Removes all controls from a group and places the control insertion point within the group. This makes it possible to have dynamic groups. After all components are added call GeDialog.LayoutChanged() with the group ID.
| Parameter: | id (int) – The control ID. |
|---|---|
| Return type: | bool |
| Returns: | True if the group was flushed. |
Flushes the menu bar of the dialog, removing all menus. Add menus with GeDialog.MenuSubBegin(). Call GeDialog.MenuFinished() when all menus and items have been added.
| Return type: | bool |
|---|---|
| Returns: | True if the menu bar was flushed. |
Closes the current menu group, opened with GeDialog.MenuSubBegin().
| Return type: | bool |
|---|---|
| Returns: | True if the menu group was ended, otherwise False. |
Adds a command item to the current menu. This can either be a C4D command or a plugin command. Particularly useful is IDM_CM_CLOSEWINDOW to add a close item for dialogs.
| Parameter: | cmdid (int) – A C4D command id or a plugin ID. |
|---|---|
| Return type: | bool |
| Returns: | True if the command was added. |
Adds a string item to the current menu. GeDialog.Command() will be called when the menu item is selected.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the menu item was added, otherwise False. |
Adds a separator to the current menu.
| Parameter: | id (int) – The item ID. |
|---|---|
| Return type: | bool |
| Returns: | True if a seperator was added. |
Call this function when all menus and all items have been added.
| Parameter: | id (int) – The item ID. |
|---|---|
| Return type: | bool |
| Returns: | True if a seperator was added. |
Used to change the enabled/disabled and checked/unchecked state of menu items. Can be called after GeDialog.MenuFinished() to update the menu item dynamically.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the item was set. |
Creates a new menu group.At the top level this means a menu, at lower levels a sub-menu. Add items with GeDiaog.MenuAddCommand(), GeDiaog.MenuAddString() or GeDiaog.MenuAddSeparator(). Call GeDiaog.MenuSubEnd() when the menu is finished.
| Parameter: | string (str) – Name of the sub menu. |
|---|---|
| Return type: | bool |
| Returns: | True if a menu group could be begun. |
Creates a new menu group.At the top level this means a menu, at lower levels a sub-menu. Add items with GeDiaog.MenuAddCommand(), GeDiaog.MenuAddString() or GeDiaog.MenuAddSeparator(). Call GeDiaog.MenuSubEnd() when the menu is finished.
| Parameter: | string (str) – Name of the sub menu. |
|---|---|
| Return type: | bool |
| Returns: | True if a menu group could be begun. |
Begins a group.
| Parameters: |
|
|---|
Ends groups.
| Return type: | bool |
|---|---|
| Returns: | True if the group was ended, otherwise False. |
Ends groups.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the spacing could be set. |
Sets the border type of the current group, and displays the title in the border if possible.
Note
Use GeDialog.GroupBorderNoTitle() if you don’t have a title. Otherwise there’ll be a small gap in the border where the title would be.
| Parameter: | borderstyle (int) – The style:
|
|---|
Sets the border type of the current group, and displays the title in the border if possible.
| Parameter: | borderstyle (int) – The style:
|
|---|
Sets the border size around the current group in pixels.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the border space was set. |
Close the dialog.
| Return type: | bool |
|---|---|
| Returns: | True if successfully closed, otherwise False. |
Sends a message to a dialog gadget.
| Parameters: |
|
|---|---|
| Return type: | object |
| Returns: | Depends on the message. |
Sends a message to the parent dialog.
| Parameter: | msg (BaseContainer) – The message container. |
|---|---|
| Return type: | bool |
| Returns: | True if the message was sent. |
Gets the dialog ID.
| Return type: | int |
|---|---|
| Returns: | The id. |
Checks if the dialog is visible.
| Return type: | bool |
|---|---|
| Returns: | True if it’s visible, otherwise False. |
Checks if the dialog is open.
| Return type: | bool |
|---|---|
| Returns: | True if it’s open, otherwise False. |
Initializes the timer clock, so that timer() is called every timer milliseconds. Use SetTimer(0) to stop the clock.
Note
Depending on the speed of the computer, the operating system, the complexity of the dialog and the threads running in the background, there is no guarantuee that event messages will occur on a regular basis. Using a value of 500 ms should be no problem but if using a value of 1 ms one might get events with the following time spaces: 3 ms, 76 ms, 15 ms, 19 ms, 67 ms...
Warning
Keep in mind that using small timer values results in heavy message traffic in the application which may slow down CINEMA 4D
| Parameter: | value (int) – The timer interval in milliseconds. |
|---|
Sets the title of the dialog window.
| Parameter: | title (str) – The title |
|---|
Enables or disables the dialog gadget, depending on the value of enabled.
| Parameters: |
|
|---|
Loads an external resource file. This is the prefered method for dialog layout since it gives maximum flexibility and easy multi language support. The dialog loaded is automatically surrounded by an additional outer group, so flags means the same as with dialog groups (e.g. BFV_CENTER).
| Parameters: |
|
|---|
Loads an external resource file. This is the prefered method for dialog layout since it gives maximum flexibility and easy multi language support. The dialog loaded is automatically surrounded by an additional outer group, so flags means the same as with dialog groups (e.g. BFV_CENTER).
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the dialog was loaded successfully. |
Sets the value of checkbox controls.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the value and limits of integer fields. Also used for tab groups, radio buttons and combo boxes.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the value, unit and limits of float fields.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the value and limits of a meter field.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the value and limits of a meter field.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the value and limits of a meter field.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the value and limits of a meter field.
| Parameters: | |
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the text of string controls. Used for all controls that have a text, for example static text fields, edit fields, buttons and checkboxes.
| Parameters: | |
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Sets the color, brightness and limits of color fields and color choosers.
| Parameters: |
|
||||||
|---|---|---|---|---|---|---|---|
| Return type: | bool |
||||||
| Returns: | True if the value was set. |
Sets the text of string controls, taking the new value from a filename.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the value was set. |
Retrieves the value of checkbox controls.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | bool |
| Returns: | The value or None if the value was not retrieved. |
Retrieves the value of integer fields. Also used for tab groups, radio buttons and combo boxes.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | int |
| Returns: | The value or None if the value was not retrieved. |
Retrieves the value of float fields.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | float |
| Returns: | The value or None if the value was not retrieved. |
Retrieves the value of three float fields at the same time as a vector.
| Parameters: | |
|---|---|
| Return type: | Vector |
| Returns: | The value or None if the value was not retrieved. |
Retrieves the text from string controls. Used for all controls that have a text, for example static text fields, edit fields, buttons and checkboxes.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | str |
| Returns: | The value or None if the value was not retrieved. |
Retrieves the color and brightness of color controls.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | dict |
| Returns: | The value or None if the value was not retrieved. |
Retrieves the time of time fields.
| Parameters: |
|
|---|---|
| Return type: | |
| Returns: | The time or None if the value was not retrieved. |
Retrieves the text from string controls as a filename.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | str |
| Returns: | The time or None if the value was not retrieved. |
Indicates wheter a control’s content has been changed since the last time it’s value was set manually with.
| Parameter: | id (C4DGadget or int) – The control ID or int. |
|---|---|
| Return type: | bool |
| Returns: | True if the control has been changed, otherwise False. |
Queries a scroll group for its currently visible region, a rectangle between (x1,y1) and (x2,y2). The coordinates are in pixels.
| Parameter: | scrollgroup (int) – The scroll group ID. |
|---|---|
| Return type: | dict of int |
| Returns: | The visible area in coordinates, in members x1, y1, x2, y2. |
Scrolls a scroll group so that the rectangle between (x1,y1) and (x2,y2) is visible. The coordinates are in pixels. If the area is smaller than the scroll group then it’s moved only as much as necessary. If the area is bigger than the scroll group then the top left corners are aligned.
| Parameters: |
|
|---|---|
| Return type: | bool |
| Returns: | True if the group was scrolled or already had the right view. |
