c4d.gui

Follow me to the Inheritance diagramm.

Functions

Note

File dialogs are stored in c4d.storage.

c4d.gui.GetInputState(askdevice, askchannel, res)

Polls a certain channel of a device for the current input state. If the return value is True, the container stored in res is just like an input event message, otherwise no state was available. For a list of valid devices and channels, Input Events.

Parameters:
  • askdevice (int) – The device to ask.
  • askdevice – The channel of the device.
  • res (BaseContainer) – The result is stored in this container.
Return type:

bool

Returns:

True if a state could be retrieved, otherwise False.

c4d.gui.GetInputEvent(askdevice, res)

Gets the next input event for a certain device from the event queue. If the return value is True, the container stored in res is just like an input event message, otherwise no event was available. For a list of valid devices and channels, please see Input Events.

Parameters:
  • askdevice (int) – The device to ask.
  • res (BaseContainer) – The result is stored in this container.
Return type:

bool

Returns:

True if the event could be retrieved, otherwise False.

c4d.gui.MessageDialog(text[, type=GEMB_OK])

Display a message dialog with the string as the message:

from c4d import gui
gui.MessageDialog("Why do you take baths in milk?'\n'I can't find a cow tall enough for a shower.")
Parameters:
  • text (str) – The string to print out.
  • type (int.) –

    The values for this are:

    GEMB_OK OK.
    GEMB_OKCANCEL OK and Cancel.
    GEMB_ABORTRETRYIGNORE Abort, Retry and Ignore.
    GEMB_YESNOCANCEL Yes, No and Cancel.
    GEMB_YESNO Yes and No.
    GEMB_RETRYCANCEL Retry and Cancel.
Return type:

int

Returns:

Result from the message box. The value for this are:

GEMB_R_OK

OK button.

GEMB_R_CANCEL

Cancel button.

GEMB_R_ABORT

Abort button.

GEMB_R_RETRY

Retry button.

GEMB_R_IGNORE

Ignore button.

GEMB_R_YES

Yes button.

GEMB_R_NO

No button.

c4d.gui.QuestionDialog(text)

Opens a standard question dialog with a question mark icon and Yes/No buttons. The text is specified as a string:

from c4d import gui
rvalue = gui.QuestionDialog("Do you think I am a dialog?")
Parameters: text (str) – The string to show.
Return type: bool
Returns: True if the user answered Yes, otherwise False.
c4d.gui.RenameDialog(text)

Opens a dialog to rename a string:

from c4d import gui

name = op.GetName() # Get the name of the active object
rvalue = gui.RenameDialog(name) # Pass it for rename
print rvalue # Returns False symbols if the user abort the dialog
Parameters: text (str) – The string
Return type: str or False
Returns: The changed string or False on abort.
c4d.gui.InputDialog(text[, preset])

Open an input dialog which returns the input string.

Return text: The label string
Return preset: The default value which will be written on popup
Return type: str
Returns: The input as string
c4d.gui.ColorDialog(flags)

Open a color chooser dialog for the user to select a color. The look of this dialog depends on the operating system.

Parameters: flags (int) – Flags.
Return type: Vector or None
Returns: A Vector on success, otherwise None if the user canceled the dialog.
c4d.gui.FontDialog()

Open a font chooser dialog for the user to select a font. The look of this dialog depends on the operating system.

Return type: BaseContainer or None
Returns: A BaseContainer with the font settings, otherwise None
c4d.gui.SelectionListDialog(arr, doc[, x][, y])

Shows a popup menu with of the given object tuple and lets the user choose an object at the position of the mouse.

Parameters:
  • arr (list of type BaseObject) – A list of BaseObjects.
  • doc (BaseDocument) – The document.
  • x (int) – X-Coordinate
  • y (int) – Y-Coordinate
Return type:

int

Returns:

The user choice or NOTOK if nothing was selected.

c4d.gui.ShowPopupDialog(cd, bc, x, y, flags=POPUP_RIGHT|POPUP_EXECUTECOMMANDS)

Displays a popup menu dialog. The menu is defined by adding string items sequentially to a BaseContainer. (i.e. the order the items are set in the container determines their order in the menu.) The ID of the string item determines its function.

Here is a complete example of the features:

import c4d
from c4d import gui

# Declare menu items ID

ID_MENU1 = c4d.FIRST_POPUP_ID
ID_MENU2 = c4d.FIRST_POPUP_ID+1
ID_MENU3 = c4d.FIRST_POPUP_ID+2
ID_MENU4 = c4d.FIRST_POPUP_ID+3

ID_SUBMENU1 = c4d.FIRST_POPUP_ID+10
ID_SUBMENU2 = c4d.FIRST_POPUP_ID+11

# Main menu

menu = c4d.BaseContainer()
menu.SetString(1, 'Title&d&')        # Append &d& to grey title entry out
menu.SetString(ID_MENU1, 'Item 1')
menu.SetString(ID_MENU2, 'Item 2')
menu.SetString(0, "")                # Append separator
menu.SetString(ID_MENU3, 'Item 3')
menu.SetString(ID_MENU4, 'Item 4')

# Sub menu

submenu = c4d.BaseContainer()
submenu.SetString(1, 'Item 3');                 # Set submenu title
submenu.SetString(ID_SUBMENU1, 'SubItem 1')
submenu.SetString(ID_SUBMENU2, 'SubItem 2&c&')  # Check this subitem

menu.SetContainer(ID_MENU3, submenu)            # Set submenu as subcontainer

# Finally show popup dialog

result = gui.ShowPopupDialog(cd=None, bc=menu, x=70, y=90)
print result
  • A string with ID=0 gives a separator:

    menu.SetString(0, '')
    
  • A string with ID=1 sets the name of the menu (used for submenus):

    submenu.SetString(1, 'Text');
    
  • IDs in the range 1000 to 899999 inserts a C4D command:

    menu.SetString(c4d.IDM_COPY, 'Copy')
    menu.SetString(c4d.IDM_PASTE, 'Paste')
    

For a list of IDs, see the c4d_symbols.h file. A special case is the c4d.IDM_CM_CLOSEWINDOW ID that will close the current dialog.

  • The same applies to plugin IDs of plugins that have a menu entry (everything above 1000000):

    menu.SetString(pluginid, 'Text');
    
  • The IDs that are left, between 900000 (c4d.FIRST_POPUP_ID) and 999999, can be used for your own menu items:

    ID_MENU1 = c4d.FIRST_POPUP_ID
    ID_MENU2 = c4d.FIRST_POPUP_ID+1
    ID_MENU3 = c4d.FIRST_POPUP_ID+2
    
Parameters:
  • cd (GeDialog) – The parent dialog.
  • bc (BaseContainer) – The container with the elements. The elements have to be strings. You can optionally set a title with the ID 0 or just start with the first element with the ID c4d.FIRST_POPUP_ID. If you set a title, we recommend to add the string ‘&d&’ to the name of the title (see example) to grey it out. The title cannot be selected, even if its not greyed out.
  • x (int) – Popup X position in screen pixels, or c4d.MOUSEPOS to popup where the cursor is.
  • y (int) – Popup Y position in screen pixels, or c4d.MOUSEPOS to popup where the cursor is.
  • flags (int) –

    One of the following flags:

    POPUP_ABOVE Open above mouse.
    POPUP_BELOW Open below mouse.
    POPUP_CENTERVERT Open centered vertically around mouse.
    POPUP_LEFT Open to the left of the mouse.
    POPUP_RIGHT Open to the right of the mouse.
    POPUP_CENTERHORIZ Open centered horizontally around mouse.
    POPUP_EXECUTECOMMANDS Execute commands immediatly.
    POPUP_ALLOWUNDOCK Allow to undock popupmenu.
    POPUP_ALLOWUNDOCK_REC Allow to undock popupmenu for children.
Return type:

int

Returns:

The ID of the selected item, or 0 if nothing was selected.

c4d.gui.GeUpdateUI()

Private.

c4d.gui.SetMousePointer(l)

Set the type of mouse pointer.

Parameters: l (int) –

Values for the mouse pointer image:

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.
c4d.gui.GetShortcutCount()

Get the global shortcut count.

Return type: int
Returns: Number of shortcuts.
c4d.gui.Shortcut2String(shortqual, shortkey)

Converts a shortcut to a readable string.

Parameters:
  • shortqual (int) – Qualifier.
  • shortkey (int) – Key.
Return type:

str

Returns:

Shortcut string.

c4d.gui.AddShortcut(bc)

Adds the shortcut in bc to the shortcut list.

Parameters: bc (BaseContainer) –

Shortcut to add. These are the IDs:

SHORTCUT_PLUGINID int Command ID.
SHORTCUT_ADDRESS int Manager ID.
ShortcutQualifier int The qualifier is stored under ID 0 + n*10, where n is 0 for single shortcuts and 0, 1, ... for shortcuts with multiple keys.
ShortcutKey int The shortcut key is stored under ID 1 + n*10.
Return type: bool
Returns: True if successful, otherwise False.
c4d.gui.RemoveShortcut(index)

Removes the shortcut at index.

Parameters: index (int) – Shortcut index, 0<=index< GetShortcutCount()
Return type: bool
Returns: True if successful, otherwise False.
c4d.gui.LoadShortcutSet(fn, add)

Load shortcuts from fn.

Parameters:
  • fn (str or MemoryFileStruct) –

    File with shortcuts to load.

    Changed in version R13.029: It is now possible to pass a memory file.

  • add (bool) – Add the shortcuts, instead of replacing.
Return type:

bool

Returns:

True if successful, otherwise False.

c4d.gui.SaveShortcutSet(fn)

Save shortcuts to fn.

Parameters: fn (str or MemoryFileStruct) –

File to save the shortcuts to.

Changed in version R13.029: It is now possible to pass a memory file.

Return type: bool
Returns: True if successful, otherwise False.
c4d.gui.GetMenuResource(menuname)

New in version R13.016.

Gets the menu container of a main menu.

Parameters: menuname (str) – Main menu name, e.g. “M_EDITOR” (the same name as on disk or that you can see in the menu editor).
Return type: BaseContainer
Returns: The menu container:
MENURESOURCE_SUBMENU BaseContainer Sub menu.
MENURESOURCE_SEPERATOR bool True if this is a separator.
MENURESOURCE_COMMAND str Command, e.g. “IDM_NEU” or “PLUGIN_CMD_1000472”.
MENURESOURCE_SUBTITLE str The title of the menu item or sub menu.
MENURESOURCE_STRING BaseContainer Menu item.
MENURESOURCE_SEPERATOR bool True if this is a separator.
MENURESOURCE_COMMAND str Command, e.g. “IDM_NEU” or “PLUGIN_CMD_1000472”.
MENURESOURCE_SUBTITLE str The title of the menu item or sub menu.
MENURESOURCE_MENURESOURCE BaseContainer Menu resource.
c4d.gui.SearchMenuResource(bc, searchstr)

New in version R13.016.

Searches a menu container for a certain plugin command (which is a string identifier, for example “PLUGIN_CMD_1000472”).

Parameters:
  • bc (BaseContainer) – Menu container to search.
  • searchstr (str) – Search string.
Return type:

bool

Returns:

True if the command was found, otherwise False.

c4d.gui.SearchPluginMenuResource([identifier="IDS_EDITOR_PLUGINS"])

New in version R13.016.

Searches for the ‘Plugins’ main category in ‘M_EDITOR’.

Parameters: identifier (str) – The resource identifier.
Return type: ptr
Returns: The found menu container, or None.
c4d.gui.SearchPluginSubMenuResource([identifier="IDS_EDITOR_PLUGINS"][, bc=None])

New in version R13.016.

Searches for the “Plugins” main category in “M_EDITOR” or optionally a submenu specified by bc.

Parameters:
  • identifier (str) – The resource identifier.
  • bc (BaseContainer) – Submenu container.
Return type:

ptr

Returns:

The found menu container, or None.

c4d.gui.UpdateMenus()

New in version R13.016.

Forces a menu update.

c4d.gui.RegisterIcon(lIconID, pBmp[, x=0][, y=0][, w=-1][, h=-1])

Registers an icon from a bitmap. Optionally a sub-icon can be specified within an larger image by giving a rectangle from (x, y) to (x+w, y+h). If no rectangle is specified the whole bitmap is used. The bitmap is internally copied.

Parameters:
  • lIconID (int) – A unique plugin ID. You must obtain this from PluginCafe.com
  • pBmp (BaseBitmap) – The bitmap to use for the icon. Is internally copied.
  • x (int) – Optional X coordinate of the top left corner of the sub-icon rectangle.
  • y (int) – Optioanl Y coordinate of the top left corner of the sub-icon rectangle.
  • w (int) – Optional width of the sub-icon rectangle.
  • h (int) – Optional height of the sub-icon rectangle.
Return type:

bool

Returns:

True if the icon was registered, otherwise False.

c4d.gui.GetIcon(lIconID)

Gets an icon registered with RegisterIcon(). Similar to InitResourceBitmap():

import c4d
from c4d import gui

icon = gui.GetIcon(c4d.RESOURCEIMAGE_MOVE)
bmp = icon["bmp"]
x, y = icon["x"], icon["y"]
Parameters: lIconID (int) – The ID of the icon. For a list of possible IDs check out InitResourceBitmap()
Return type: dict{bmp: BaseBitmap, x: int, y: int, w: int, h: int}
Returns: A dictionary with the information about the icon data.
c4d.gui.UnregisterIcon(lIconID)

Unregisters the icon with ID lIconID. Only unregister your own registered icons.

Parameters: lIconID (int) – The ID of the icon.
Return type: bool
Returns: True if the icon was unregistered, otherwise False.
c4d.gui.GetShortcut(index)

Gets the shortcut at index.

Parameters: index (int) – Shortcut index, 0<=index< GetShortcutCount
Return type: BaseContainer
Returns: The retrieved shortcut.
c4d.gui.SizePixChr(pixels, chars)

Combines the SizePix() and SizeChr() functions. The returned value is interpreted as a number of characters/lines plus a number of pixels.

Parameters:
  • pixels (int) – The pixel dimension.
  • chars (int) – The number of characters.
Return type:

int

Param :

The size value.

c4d.gui.SizePix(pixels)

Bakes a pixel size so that it can be used to specify dialog control dimension.

Parameters: pixels (int) – The pixel dimension.
Return type: int
Param : The size value.
c4d.gui.SizeChr(chars)

Bakes a character count so that it can be used to specify dialog control dimension. (How many characters that will fit in a control for widths, and how many standard lines that will fit for heights.)

Parameters: chars (int) – The number of characters.
Return type: int
Returns: The size value.
c4d.gui.GeGetScreenDimensions(x, y, whole_screen)

New in version R13.016.

Returns the screen dimensions in pixels.

Parameters:
  • x (int) – Screen X coordinates to identify which display information is read (for multi-display setups).
  • y (int) – Screen Y coordinates to identify which display information is read (for multi-display setups).
  • whole_screen (bool) – True if dimensions of the whole screen (including taskbar etc.) are returned, otherwise False.
Return type:

dict{sx1: int, sy1: int, sx2: int, sy2: int}

Returns:

A dictionary with the screen dimensions:

type sx1: int
key sx1: The minimum X coordinate (left).
type sy1: int
key sy1: The minimum Y coordinate (top).
type sx2: int
key sx2: The maximum X coordinate (right).
type sy2: int
key sy2: The maximum Y coordinate (bottom).

c4d.gui.ActiveObjectManager_SetObject(id, op, flags[, activepage=DescID()])

New in version R13.029.

Sets the currently shown object op in the specified mode.

Note

You only need to use this if you have registered your own mode without a hook. Otherwise the managers will ask for new objects themselves, and listen for events when new objects are selected.

Parameters:
  • id (int) –

    Mode ID:

    ACTIVEOBJECTMODE_OBJECT Object mode.
    ACTIVEOBJECTMODE_TAG Tag mode.
    ACTIVEOBJECTMODE_MATERIAL Material mode.
    ACTIVEOBJECTMODE_SHADER Shader mode.
    ACTIVEOBJECTMODE_NODE Node mode.
    ACTIVEOBJECTMODE_TIMELINE Time-line mode.
    ACTIVEOBJECTMODE_FCURVE F-curve mode.
    ACTIVEOBJECTMODE_BITMAPINFO BodyPaint bitmap info mode.
    ACTIVEOBJECTMODE_TOOL Tool mode.
    ACTIVEOBJECTMODE_VIEW View mode.
    ACTIVEOBJECTMODE_INFOTAB Info tab.
    ACTIVEOBJECTMODE_CAMERA Editor camera mode.
    ACTIVEOBJECTMODE_RENDERDATA Render data mode.
    ACTIVEOBJECTMODE_DOCUMENT Document settings mode.
  • op (C4DAtom) – Object to show.
  • flags (int) –

    Flags:

    ACTIVEOBJECTMANAGER_SETOBJECTS_OPEN A new manager is opened if there’s no manager that accepts the given id, for example if the other managers are locked or have that mode disabled.
    ACTIVEOBJECTMANAGER_SETOBJECTS_NOMODESWITCH If the AM already shows the mode of the objects being set, it will switch to the new objects. If the AM has another mode the old mode and objects stay.
  • activepage (DescID) – The tab of the object’s description to be shown. Pass the descritpion ID of the tab here.

Table Of Contents