c4d.gui

Follow me to the Inheritance diagramm.

Functions

Note

File dialogs are defined 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.

See also

Input Events.

Parameters:
  • askdevice (int) –

    The device to ask.. One of the following types:

    BFM_INPUT_MOUSE Mouse
    BFM_INPUT_KEYBOARD Keyboard
  • askchannel (int) –

    The channel contains the key or button (‘A’ means A, KEY_F1 means F1):

    BFM_INPUT_MOUSELEFT Left mouse button.
    BFM_INPUT_MOUSERIGHT Right mouse button.
    BFM_INPUT_MOUSEMIDDLE Middle mouse button.
    BFM_INPUT_MOUSEX1 Fourth mouse button.
    BFM_INPUT_MOUSEX2 Five mouse button.
    BFM_INPUT_MOUSEWHEEL Mouse wheel message.
    BFM_INPUT_MOUSEMOVE Mouse move message.
  • res (c4d.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.

See also

Input Events.

Parameters:
  • askdevice (int) –

    The device to ask. One of the following types:

    BFM_INPUT_MOUSE Mouse
    BFM_INPUT_KEYBOARD Keyboard
  • res (c4d.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.")
../../_images/messagedialog.png
Parameters:
  • text (str) – The string to print out.
  • type (int.) –

    The values 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?")
../../_images/questiondialog.png
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 standard rename dialog:

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 None if the user aborts the dialog
../../_images/renamedialog.png
Parameters:text (str) – The string with the name to change.
Return type:str
Returns:The changed string on success, otherwise None if the user canceled the dialog.
c4d.gui.InputDialog(text[, preset])

Opens 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[, col = c4d.Vector()])

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

../../_images/choose_color.png
Parameters:
  • flags (int) – Flags.
  • col (c4d.Vector) –

    New in version R19.024.

    The default color.

Return type:

c4d.Vector

Returns:

A Vector on success, otherwise None if the user canceled the dialog.

c4d.gui.FontDialog()

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

../../_images/choose_font.png
Return type:c4d.BaseContainer
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:
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

IDM_MENU1 = c4d.FIRST_POPUP_ID
IDM_MENU2 = c4d.FIRST_POPUP_ID+1
IDM_MENU3 = c4d.FIRST_POPUP_ID+2
IDM_MENU4 = c4d.FIRST_POPUP_ID+3

IDM_SUBMENU1 = c4d.FIRST_POPUP_ID+10
IDM_SUBMENU2 = c4d.FIRST_POPUP_ID+11

# Main menu

menu = c4d.BaseContainer()
menu.InsData(IDM_MENU1, 'Item 1')
menu.InsData(IDM_MENU2, 'Item 2')
menu.InsData(0, '')                # Append separator

# Sub menu

submenu = c4d.BaseContainer()
submenu.InsData(1, 'Item 3')                   # Set submenu title
submenu.InsData(IDM_SUBMENU1, 'SubItem 1')
submenu.InsData(IDM_SUBMENU2, 'SubItem 2&c&')  # Check this subitem

menu.SetContainer(IDM_MENU3, submenu)          # Set submenu as subcontainer
menu.InsData(0, '')                            # Append separator

# Add another item to the menu

menu.InsData(IDM_MENU4, 'Item 4&d&')  # Disable this item

# Finally show popup dialog

result = gui.ShowPopupDialog(cd=None, bc=menu, x=300, y=300)
print result
../../_images/popudialogexample.png
  • A string with ID=0 gives a separator:

    menu.InsData(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 Cinema 4D 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 (c4d.gui.GeDialog) – The parent dialog.
  • bc (c4d.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)

Sets 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()

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

Loads shortcuts from fn.

Parameters:
  • fn (str or MemoryFileStruct) – File with shortcuts to load.
  • add (bool) – Add the shortcuts, instead of replacing.
Return type:

bool

Returns:

True if successful, otherwise False.

c4d.gui.SaveShortcutSet(fn)

Saves shortcuts to fn.

Parameters:fn (str or MemoryFileStruct) – File to save the shortcuts to.
Return type:bool
Returns:True if successful, otherwise False.
c4d.gui.GetMenuResource(menuname)

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:c4d.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)

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

Parameters:
  • bc (c4d.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”])

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.

Note

To get the actual menu container use c4d.Cast():

res = gui.SearchPluginMenuResource()
bc = c4d.Cast(None, res)
c4d.gui.SearchPluginSubMenuResource([identifier=”IDS_EDITOR_PLUGINS”][, bc=None])

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

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

ptr

Returns:

The found menu container, or None.

Note

To get the actual menu container use c4d.Cast():

res = gui.SearchPluginMenuResource()
bc = c4d.Cast(None, res)

c4d.gui.UpdateMenus()

Forces a menu update.

c4d.gui.GetInterfaceIcon(type, id_x, id_y, id_w, id_h)

New in version R14.014.

Returns the icon for an interface element.

Parameters:
  • type (int) –

    Flags:

    INTERFACE_ICON_TYPE_NORMAL Icon - normal.
    INTERFACE_ICON_TYPE_DISABLED Icon - disabled.
    INTERFACE_ICON_TYPE_FOCUS Icon - focus.
  • id_x (int) – The X position ID of the icon.
  • id_y (int) – The Y position ID of the icon.
  • id_w (int) – The width ID of the icon.
  • id_h (int) – The height ID of the icon.
Return type:

dict{bmp: BaseBitmap, flags: int, w: int, h: int, x: int, y: int}

Returns:

The icon ressource data, or None if an error occured.

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 (c4d.bitmaps.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: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:c4d.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)

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()])

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.
    ACTIVEOBJECTMODE_MODELING Modeling mode.
  • op (c4d.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 (c4d.DescID) – The tab of the object’s description to be shown. Pass the descritpion ID of the tab here.