c4d.gui.GeUserArea

This class helps you to create custom gadgets for dialogs in Cinema 4D.

Note

Just take care about the lifetime of your GeUserArea instance. If you pass an instance of this class to a dialog, a reference is hold by the dialog and released when the dialog is freed. That also means that each instance of your GeUserArea class is still alive until the host-dialog is freed, even you dont hold a reference to it. If you want to use the same instance of your GeUserArea class on the next time you open the dialog, you have to store the instance in the class scope. See the following example.

The class to create custom user areas.

Definition

class c4d.gui.GeUserArea

Members

GeUserArea.__init__()
Return type:c4d.gui.GeUserArea
Returns:A new user area.
GeUserArea.Init(self)

Called once when the user area is initialized by the GUI, before the layout is calculated. Override this function if you need to initialize anything. Return True if successful, or False to signalize an error.

Return type:bool
Returns:True if successful, or False to signalize an error.
GeUserArea.InitValues(self)

Called after the layout is calculated, before the user area is drawn. Override this function if you need to initialize anything. Return True if successful, or False to signalize an error.

Return type:bool
Returns:True if successful, or False to signalize an error.
GeUserArea.GetMinSize(self)

Override this function to specify a minimum size for the user area:

def GetMinSize(self):
  #do a calculation here
  return self.width, self.height
Return type:tuple(int, int)
Returns:A tuple with two elements just like this.
GeUserArea.DrawMsg(self, x1, y1, x2, y2, msg)

Called when Cinema 4D wants you to draw your userarea. Use the drawing functions to update your user area in the region speicified by the rectangle from (x1,y1) to (x2,y2).

Parameters:
  • x1 (int) – The upper left x coordinate.
  • y1 (int) – The upper left y coordinate.
  • x2 (int) – The lower right x coordinate.
  • y2 (int) – The lower right y coordinate.
GeUserArea.InputEvent(self, msg)

Called when an input event is received. All information about the input event is stored in the msg container.

Parameters:msg (c4d.BaseContainer) – The event container.
Return type:bool
Returns:True if the event was handled, otherwise False.
GeUserArea.CoreMessage(self, id, msg)

Called when a Cinema 4D core messages is received. The message type is given by id and the message information is stored in msg.

Parameters:
  • id (int) –

    The message ID:

    EVMSG_CHANGE Sent by the EventAdd() function.
    EVMSG_DOCUMENTRECALCULATED This message is sent while drawing after the animation, expressions and cachebuild have been done. It allows that certain managers (e.g. attribute manager) update their values to the changes done by the expressions etc. Any reactions on this message should be pretty fast! Also please note that no modifying stuff must be done here as the draw thread is running at the same time and accesses the same data!
    EVMSG_TOOLCHANGED A tool setting has changed (local event).
    EVMSG_GRAPHVIEWCHANGED Something in XPresso has been changed (local event).
    EVMSG_AUTKEYMODECHANGED The autokey mode was changed.
    EVMSG_UPDATEHIGHLIGHT A special message sent by Cinema 4D in the case that only the highlighting changes. This happens for example when you move the mouse over the viewport. Plugins usually do not need to care about this.
    EVMSG_CHANGEDSCRIPTMODE Sent when the script mode (Python, C.O.F.F.E.E.) changed.
    EVMSG_SHOWIN_SB Show in Scene Browser.
    EVMSG_SHOWIN_TL Show in Timeline.
    EVMSG_SHOWIN_FC Show in Function Curve editor.
    EVMSG_SHOWIN_LM Show in Layer Manager.
    EVMSG_TLOM_MERGE Private.
    EVMSG_SHOWIN_MT Show in Motion editor.
    EVMSG_TIMELINESELECTION A timeline selection has been changed (local event).
    EVMSG_BROWSERCHANGE Something in the browser has been changed (local event).
    EVMSG_MATERIALSELECTION A material selection has been changed (local event).
    EVMSG_FCURVECHANGE Something in the F-Curve manager has been changed (local event).
    EVMSG_RAYTRACER_FINISHED Private.
    EVMSG_MATERIALPREVIEW Private.
    EVMSG_ACTIVEVIEWCHANGED Private.
    EVMSG_ASYNCEDITORMOVE The user moved something in the editor window. Managers should update things like position fields.
    EVMSG_TIMECHANGED Private.
    EVMSG_VIEWWINDOW_OUTPUT Private.
    EVMSG_VIEWWINDOW_3DPAINTUPD Private.
    EVMSG_UPDATESCHEME Scheme has been updated.
    EVMSG_TAKECHANGED

    New in version R17.032.

    Sent by the Take System when the current Take ID changed to let all managers react to the new status.

  • msg (c4d.BaseContainer) – The message container.
Return type:

bool

Returns:

Currently not used - but you have to return a bool value.

GeUserArea.Sized(self, w, h)

Called when the user area is resized. Override if you need to update anything.

Parameters:
  • w (int) – The new width in pixels.
  • h (int) – The new height in pixels.
GeUserArea.Timer(self, msg)

If you subscribe to timer events using SetTimer() (x), this function is called every x th millisecond. The raw timer message is stored in msg.

Parameters:msg (c4d.BaseContainer) – The timer message container.
GeUserArea.Message(self, msg, result)

Override this function if you want to react to more messages than covered by the other functions. Normally this is not necessary. Be sure to include a call the parent version of this function, Message():

def Message(self, msg, result):
  if msg.GetId():
    pass #do something
    return True

  return GeUserArea.Message(self, msg, result)
Parameters:
Return type:

int

Returns:

The return value depends on the message.

GeUserArea.Redraw([thread=False])

Forces the user area to redraw itself.

Parameters:thread (bool) – Must be set to True if the function is called from another thread than the main Cinema 4D thread.
GeUserArea.SendParentMessage(msg)

Use this function to send a custom message to the parent dialog.

Parameters:msg (c4d.BaseContainer) – The message container.
GeUserArea.GetId()

Returns the ID of the user area.

Return type:int
Returns:The ID.
GeUserArea.GetWidth()

Returns the width of the user area.

Return type:int
Returns:Width in pixels.
GeUserArea.GetHeight()

Returns the height of the user area.

Return type:int
Returns:Height in pixels.
GeUserArea.IsEnabled()

Indicates the enabled state.

Return type:bool
Returns:True if the user area is enabled in the dialog, otherwise False.
GeUserArea.HasFocus()

Indicates the focus state.

Return type:bool
Returns:True if the user area has the focus in the dialog, otherwise False.
GeUserArea.SetTimer(x)

Initializes the timer clock, so that Timer() is called every timer milliseconds.

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…

Note

Keep in mind that using small timer values results in heavy message traffic in the application which may slow down Cinema 4D (and all other applications running on the computer) to a point where nothing is working any longer besides your dialog.

Parameters:x (int) – The timer interval in milliseconds.
GeUserArea.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.

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

GeUserArea.KillEvents()

Flushes all events from the window message queue. For example if you loop while the mouse is down (polling) you can call this command to flush all keydowns/mouseclicks that are made during the loop.

GeUserArea.IsHotkeyDown(id)

Checks the standard navigation hotkeys.

Parameters:id (int) –

The hotkey:

HOTKEY_CAMERA_MOVE Camera move.
HOTKEY_CAMERA_SCALE Camera scale
HOTKEY_CAMERA_ROTATE Camera rotate.
HOTKEY_OBJECT_MOVE Object move.
HOTKEY_OBJECT_SCALE Object scale
HOTKEY_OBJECT_ROTATE Object rotate.
HOTKEY_SELECT_FREE Freehand selection.
HOTKEY_SELECT_LIVE Live selection.
HOTKEY_SELECT_RECT Rectangle selection.
HOTKEY_MODEL_SCALE Model scale.
HOTKEY_ZOOM Zoom.
HOTKEY_PARENT_MOVE Parent object move.
HOTKEY_RESIZE_BRUSH Resize brush.
Return type:bool
Returns:True if the hotkey is down.
GeUserArea.GetColorRGB(colorid)

Gets the RGB values associated with a color code.

Parameters:type (int) –

A color constant:

COLOR_3DTEXT  
COLOR_XOR  
COLOR_TRANS  
COLOR_BG  
COLOR_BGEDIT  
COLOR_BGFOCUS  
COLOR_TEXT  
COLOR_TEXTFOCUS  
COLOR_EDGELT  
COLOR_EDGEWH  
COLOR_EDGEDK  
COLOR_EDGEBL  
COLOR_DBARFG1  
COLOR_DBARBG1  
COLOR_DBARFG2  
COLOR_DBARBG2  
COLOR_BGGADGET  
COLOR_BGSELECTEDTEXT  
COLOR_FGSELECTEDTEXT  
COLOR_TIMELINE  
COLOR_BGTRISTATE  
COLOR_BG_DARK1  
COLOR_BG_DARK2  
COLOR_CTIMELINE_GRIDMEDIUM

New in version R17.032.

COLOR_SB_CARET

New in version R17.032.

COLOR_SB_CARETBG

New in version R17.032.

COLOR_TEXT_AUTOTAKE

New in version R17.032.

COLOR_TEXT_AUTOTAKE_DARK

New in version R17.032.

Return type:dict{r: int, g: int, b: int}
Returns:The color or None.
GeUserArea.DrawSetPen(color)

Sets the draw color.

Param:A color vector.
GeUserArea.DrawSetTextCol(fg, bg)

Sets the draw color.

Parameters:
GeUserArea.DrawLine(x1, y1, x2, y2)

Draws a line with the current pen color between (x1,y1) and (x2,y2).

Parameters:
  • x1 (int) – The X start coordinate.
  • y1 (int) – The Y start coordinate.
  • x2 (int) – The X end coordinate.
  • y2 (int) – The Y end coordinate.
GeUserArea.DrawRectangle(x1, y1, x2, y2)

Fills a rectangular area with the current pen color between (x1,y1) and (x2,y2).

Parameters:
  • x1 (int) – The X coordinate of the first corner.
  • y1 (int) – The Y coordinate of the first corner.
  • x2 (int) – The X coordinate of the opposite corner.
  • y2 (int) – The Y coordinate of the opposite corner.
GeUserArea.DrawBitmap(bmp, wx, wy, ww, wh, x, y, w, h, mode)

Draws a bitmap into the user area. The region (x,y) to (x+w,y+h) from the bitmap will be scaled and transformed into the region (wx,wy) to (wx+ww,wy+wh) of the destination area.

Note

BMP_ALLOWALPHA can be combined with the other modes.

Parameters:
  • bmp (c4d.bitmaps.BaseBitmap) – The bitmap to draw.
  • wx (int) – X coordinate of the upper left corner of the destination area.
  • wy (int) – Y coordinate of the upper left corner of the destination area.
  • ww (int) – Width of the destination area.
  • wh (int) – Height of the destination area.
  • x (int) – X coordinate of the upper left corner of the bitmap area.
  • y (int) – Y coordinate of the upper left corner of the bitmap area.
  • w (int) – Width of the bitmap area.
  • h (int) – Height of the bitmap area.
  • mode (int) –

    Can be a combination of the following flags:

    BMP_NORMAL Standard scaling by the operating system. Fast but low quality when using uneven scaling factors.
    BMP_NORMALSCALED Scaling with sampling for high quality. Slow.
    BMP_EMBOSSED Embosses the bitmap (like the grayed palette icons in Cinema 4D).
    BMP_APPLY_COLORPROFILE Applies the color profile.
    BMP_DIMIMAGE Darkens the bitmap (like the activated palette icons in Cinema 4D)
    BMP_ALLOWALPHA Use the alpha channel to blend with background.
    BMP_APPLY_COLORPROFILE Applies the color profile.
    BMP_DIMIMAGE Darkens the bitmap (like the activated palette icons in Cinema 4D)
    BMP_MIRROR_H Mirrors the bitmap horizontally.
    BMP_MIRROR_H_FORBID Do not mirror the bitmap horizontally.
    BMP_MIRROR_V Mirrors the bitmap vertically.
    BMP_MIRROR_V_FORBID Do not mirror the bitmap vertically.
GeUserArea.DrawBorder(type, x1, y1, x2, y2)

Fills a rectangular area with the current pen color between (x1,y1) and (x2,y2).

Parameters:
  • type (int) –

    The border type. Possible values:

    BORDER_NONE No border.
    BORDER_THIN_IN Thin border inward.
    BORDER_THIN_OUT Thin border outward.
    BORDER_IN Normal border inward.
    BORDER_OUT Normal border outward.
    BORDER_GROUP_IN Group border inside.
    BORDER_GROUP_OUT Group border outside.
    BORDER_OUT2 Outward border 2.
    BORDER_OUT3 Outward border 3
    BORDER_BLACK Thin black line.
    BORDER_ACTIVE_1 Active border 1.
    BORDER_ACTIVE_2 Active border 2.
    BORDER_ACTIVE_3 Active border 3.
    BORDER_ACTIVE_4 Active border 4.
    BORDER_GROUP_TOP Border along the top.
    BORDER_ROUND Border with round corners.
    BORDER_SCHEME_EDIT Edit field border like the shortcut gadget for example.
    BORDER_SCHEME_EDIT_NUMERIC Edit field border that is open to the right like the link field for example.
    BORDER_OUT3l Outward border 3, open to the left.
    BORDER_OUT3r Outward border 3, open to the right.
    BORDER_MASK Masks out border type.
    BORDER_WITH_TITLE_BOLD Display group title with bold font.
    BORDER_WITH_TITLE Display group title in the border.
  • x1 (int) – The X coordinate of the first corner.
  • y1 (int) – The Y coordinate of the first corner.
  • x2 (int) – The X coordinate of the opposite corner.
  • y2 (int) – The Y coordinate of the opposite corner.
GeUserArea.DrawText(text, x, y[, flags=DRAWTEXT_STD_ALIGN])

Draws the string txt with the upper left corner at the position (x, y). Use DrawGetTextWidth() and DrawGetFontHeight() to find out where to place the text.

Parameters:
  • text (str) – The string to draw.
  • x (int) – X coordinate of the upper left corner of the drawn text.
  • y (int) – Y coordinate of the upper left corner of the drawn text.
  • flags (int) – Flags.
GeUserArea.DrawBezier(sx, sy, p, closed, filled)

New in version R14.014.

Draws concatenated bezier curves.

Note

Due to improve speed performance, the elements of p will be modified and might be invalid and all values must be set again if DrawBezier() will be called again with the same array.

Parameters:
  • sx (float) – X coordinate of the upper left corner of the drawn curve. This is the X coordinate of the starting point.
  • sy (float) – Y coordinate of the upper left corner of the drawn curve. This is the Y coordinate of the starting point.
  • p (array of float) –

    An array with the bezier curves points.

    The following values ease the initialization of the points array:

    DRAWBEZIER_BX X coordinate of the control point for the starting point.
    DRAWBEZIER_BY Y coordinate of the control point for the starting point.
    DRAWBEZIER_CX X coordinate of the control point for the ending point.
    DRAWBEZIER_CY Y coordinate of the control point for the ending point.
    DRAWBEZIER_DX X coordinate of the ending point.
    DRAWBEZIER_DY Y coordinate of the ending point.

    Here is an example of initializing the curve points array:

    points = array.array(‘f’, xrange(6))
    
    points[c4d.DRAWBEZIER_BX] = 35
    points[c4d.DRAWBEZIER_BY] = 200
    points[c4d.DRAWBEZIER_CX] = 220
    points[c4d.DRAWBEZIER_CY] = 260
    points[c4d.DRAWBEZIER_DX] = 220
    points[c4d.DRAWBEZIER_DY] = 40
    
    self.DrawBezier(120, 160, points, False, False)
    
  • closed (bool) – If True, the last point of the last segment connects back to the starting point ( sx , sy).
  • filled (bool) – If True, fills the drawn bezier curves, only if it is also closed.
GeUserArea.FillBitmapBackground(bmp, offsetx, offsety)

Fills the bitmap bmp with the current pen color. The offsetx and offsety parameters are used when the background is a pattern and are given in local coordinates of the user area. This can be used to make semi-transparent bitmap blits.

Parameters:
  • bmp (c4d.bitmaps.BaseBitmap) – The bitmap to fill.
  • offsetx (int) – The X offset in pixels.
  • offsety (int) – The X offset in pixels.
GeUserArea.DrawSetFont(fontid)

Sets the text font.

Parameters:fontid (int) –

The font to use:

FONT_DEFAULT Default font.
FONT_STANDARD Standard font.
FONT_BOLD Bold font.
FONT_MONOSPACED Monospaced font.
GeUserArea.DrawGetTextWidth(text)

Returns the width in pixels of the string text, if it were drawn in the current font.

Parameters:text (str) – The string to measure.
Return type:int
Returns:The width in pixels.
GeUserArea.DrawGetFontHeight()

Returns the height in pixels of a line of text in the current font.

Return type:int
Returns:Height in pixels.
GeUserArea.DrawGetFontBaseLine()

Returns the base line of the set font.

Return type:int
Returns:The base line of the set font.
GeUserArea.DrawSetTextRotation(textrotation)

Rotates the font for drawing.

Note

Rotation is clockwise and must be set to 0 after drawing.

Parameters:textrotation (float) – The text rotation in degree.
GeUserArea.SetClippingRegion(x, y, w, h)

Should be used at the top of the DrawMsg() function to specify the clipping region. Without specifying a dedicated clipping region everything will be painted, even if it is outside the user area!

Note

The method OffScreenOn() automatically sets the clipping region to the whole user area, so normally this function is not necessary.

Parameters:
  • x (int) – X coordinate of the upper left corner of the clipping region.
  • y (int) – Y coordinate of the upper left corner of the clipping region.
  • w (int) – Width of the clipping region.
  • h (int) – Height of the clipping region.
GeUserArea.ClearClippingRegion()

Clears any clipping region set with SetClippingRegion().

GeUserArea.OffScreenOn([x, y, w, h])

Enables double buffering to avoid blinking and flickering effects. The GUI will automatically switch planes. Just call this function before drawing things. Sets the clipping area to the rectangular area determined by x, y, w and h.

Parameters:
  • x (int) – X-coordinate of the clipping area.
  • y (int) – Y-coordinate of the clipping area.
  • w (int) – Width of the clipping area.
  • h (int) – Height of the clipping area.
Return type:

bool

Returns:

True if double buffering could be enabled, otherwise False.

GeUserArea.ScrollArea(xdiff, ydiff, x, y, w, h)

Scrolls the area from (x,y) to (x+w,y+h) in the direction specified by xdiff and ydiff.

Parameters:
  • xdiff (int) – X distance to scroll.
  • ydiff (int) – Y distance to scroll.
  • x (int) – X coordinate of the upper left corner of the area to scroll.
  • y (int) – Y coordinate of the upper left corner of the area to scroll.
  • w (int) – Width of the area to scroll.
  • h (int) – Height of the area to scroll.
GeUserArea.ActivateFading(milliseconds)

New in version R14.014.

Activates the fading.

Parameters:milliseconds (int) – Time for the fading.
GeUserArea.AdjustColor(colorid, highlightid, percent)

New in version R14.014.

Sets the blend colors for user area fading.

Parameters:
  • colorid (int) –

    A color id to fade from:

    COLOR_3DTEXT  
    COLOR_XOR  
    COLOR_TRANS  
    COLOR_BG  
    COLOR_BGEDIT  
    COLOR_BGFOCUS  
    COLOR_TEXT  
    COLOR_TEXTFOCUS  
    COLOR_EDGELT  
    COLOR_EDGEWH  
    COLOR_EDGEDK  
    COLOR_EDGEBL  
    COLOR_DBARFG1  
    COLOR_DBARBG1  
    COLOR_DBARFG2  
    COLOR_DBARBG2  
    COLOR_BGGADGET  
    COLOR_BGSELECTEDTEXT  
    COLOR_FGSELECTEDTEXT  
    COLOR_TIMELINE  
    COLOR_BGTRISTATE  
    COLOR_BG_DARK1  
    COLOR_BG_DARK2  
    COLOR_CTIMELINE_GRIDMEDIUM

    New in version R17.032.

    COLOR_SB_CARET

    New in version R17.032.

    COLOR_SB_CARETBG

    New in version R17.032.

    COLOR_TEXT_AUTOTAKE

    New in version R17.032.

    COLOR_TEXT_AUTOTAKE_DARK

    New in version R17.032.

  • highlightid (int) –

    A color id to fade to:

    COLOR_3DTEXT  
    COLOR_XOR  
    COLOR_TRANS  
    COLOR_BG  
    COLOR_BGEDIT  
    COLOR_BGFOCUS  
    COLOR_TEXT  
    COLOR_TEXTFOCUS  
    COLOR_EDGELT  
    COLOR_EDGEWH  
    COLOR_EDGEDK  
    COLOR_EDGEBL  
    COLOR_DBARFG1  
    COLOR_DBARBG1  
    COLOR_DBARFG2  
    COLOR_DBARBG2  
    COLOR_BGGADGET  
    COLOR_BGSELECTEDTEXT  
    COLOR_FGSELECTEDTEXT  
    COLOR_TIMELINE  
    COLOR_BGTRISTATE  
    COLOR_BG_DARK1  
    COLOR_BG_DARK2  
    COLOR_CTIMELINE_GRIDMEDIUM

    New in version R17.032.

    COLOR_SB_CARET

    New in version R17.032.

    COLOR_SB_CARETBG

    New in version R17.032.

    COLOR_TEXT_AUTOTAKE

    New in version R17.032.

    COLOR_TEXT_AUTOTAKE_DARK

    New in version R17.032.

  • percent (float) – Fading percentage.
GeUserArea.Local2Global()

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{x: int, y: int}
Returns:The converted coordinates or None.
GeUserArea.Global2Local()

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{x: int, y: int}
Returns:The converted coordinates or None.
GeUserArea.Local2Screen()

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{x: int, y: int}
Returns:The converted coordinates or None.
GeUserArea.Screen2Local()

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{x: int, y: int}
Returns:The converted coordinates or None.
GeUserArea.LayoutChanged()

Tells Cinema 4D that the user area now has new dimensions. That causes c4d to call:

GeUserArea.GetDragPosition(msg)

Extracts local drag coordinates from a drag and drop event.

Parameters:msg (c4d.BaseContainer) – The original message.
Return type:dict{‘x’: int, ‘y’: int}
Returns:The local X and Y position.
GeUserArea.GetDragObject(msg)

Extracts the object from a drag and drop message.

Parameters:msg (c4d.BaseContainer) – The original message.
Return type:dict{‘type’: int, ‘object’: any}
Returns:The type of drag and the object itself. The types are:
DRAGTYPE_ATOMARRAY Atom array. The data is a list of c4d.C4DAtom.
DRAGTYPE_CMDPALETTE Not supported.
DRAGTYPE_COMMAND Not supported.
DRAGTYPE_DESCID Description ID. The data is a dict(‘did’: c4d.DescID, ‘arr’: list of c4d.C4DAtom).
DRAGTYPE_ICON Not supported.
DRAGTYPE_FILES Files. The data is a string with the filename.
DRAGTYPE_FILENAME_IMAGE Image. The data is a string with the filename.
DRAGTYPE_FILENAME_OTHER Other filename. The data is a string with the filename.
DRAGTYPE_FILENAME_SCENE Scene filename. The data is a string with the filename.
DRAGTYPE_MANAGER Not supported.
DRAGTYPE_RGB RGB color. The data is a c4d.Vector.
DRAGTYPE_RGB_ARRAY RGB color array. The data is a list of c4d.Vector.
GeUserArea.HandleMouseDrag(msg, type, data, dragflags)

New in version R19.024.

Starts a drag and drop operation.

Parameters:
  • msg (c4d.BaseContainer) – The mouse event message that triggered the drag and drop.
  • type (int) –

    The type of data:

    DRAGTYPE_ATOMARRAY Atom array. The data is a list of c4d.C4DAtom.
    DRAGTYPE_CMDPALETTE Not supported.
    DRAGTYPE_COMMAND Not supported.
    DRAGTYPE_DESCID Description ID. The data is a dict(‘did’: c4d.DescID, ‘arr’: list of c4d.C4DAtom).
    DRAGTYPE_ICON Not supported.
    DRAGTYPE_FILES Files. The data is a string with the filename.
    DRAGTYPE_FILENAME_IMAGE Image. The data is a string with the filename.
    DRAGTYPE_FILENAME_OTHER Other filename. The data is a string with the filename.
    DRAGTYPE_FILENAME_SCENE Scene filename. The data is a string with the filename.
    DRAGTYPE_MANAGER Not supported.
    DRAGTYPE_RGB RGB color. The data is a c4d.Vector.
    DRAGTYPE_RGB_ARRAY RGB color array. The data is a list of c4d.Vector.
  • data (any) – Depends on type.
  • dragflags (int) – The drag flags. Private.
Return type:

bool

Returns:

True if the user moved the mouse and a drag and drop operation was initiated.
False if the user did not move the mouse, so that the original event is a normal mouse click event.

GeUserArea.SetDragDestination()

Sets the correct cursor during drag and drop handling.

Parameters:cursor (int) –

A mouse cursor:

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:True if the cursor could be set, otherwise False.
GeUserArea.CheckDropArea(msg, horiz, vert)

Checks the drag position in a drag event message against the user area’s position in the layout. The check can be limited to only X or Y coordinates.

Parameters:
  • msg (c4d.BaseContainer) – The drag message.
  • horiz (bool) – If True the drag position is checked against the horizontal bounds of the region.
  • vert (bool) – If True the drag position is checked against the vertical bounds of the region.
Return type:

bool

Returns:

True if the drag message is within the bounds specified, otherwise False.

GeUserArea.MouseDragStart(button, mx, my, flag)

Starts a mouse drag. Only call this when a mouse down message is received. Then repeatedly poll with MouseDrag() during the drag.

Parameters:
  • button (int) –

    The mouse button that is pressed:

    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.
  • mx (float) – The X position of the mouse.
  • my (float) – The Y position of the mouse.
  • flag (int) –

    The mouse drag flags:

    MOUSEDRAGFLAGS_DONTHIDEMOUSE Show mouse pointer during drag.
    MOUSEDRAGFLAGS_NOMOVE MouseDrag() returns MOUSEDRAGRESULT_CONTINUE even if mouse is not moved. Otherwise MouseDrag() only returns if mouse is moved.
    MOUSEDRAGFLAGS_EVERYPACKET Receive every packet of the queue, otherwise only data of the last packet.
    MOUSEDRAGFLAGS_COMPENSATEVIEWPORTORG Compensates the viewport origin during drag.
    MOUSEDRAGFLAGS_AIRBRUSH Airbrush mode.
GeUserArea.MouseDrag()

Polls the mouse during a drag started with MouseDragStart().

The best way to use this function is:

while True:
    result, mx, mx, channels = ua.MouseDrag()
    if result != c4d.MOUSEDRAGRESULT_CONTINUE:
        break

To check for qualifiers see the channels container:

if channels[c4d.BFM_INPUT_QUALIFIER] & QSHIFT:
    ...
if channels[c4d.BFM_INPUT_QUALIFIER] & QCTRL:
    ...
Return type:tuple(int, float, float, c4d.BaseContainer)
Returns:A tuple with the following information:

int: The mouse drag result:

MOUSEDRAGRESULT_ESCAPE Drag aborted.
MOUSEDRAGRESULT_FINISHED Drag finished.
MOUSEDRAGRESULT_CONTINUE Drag still in progress.
float: The X delta-coordinate of the mouse (the amount the mouse has moved).
float: The Y delta-coordinate of the mouse (the amount the mouse has moved).
c4d.BaseContainer: The channels values. Also contains these pen values:
PENPRESSURE Pressure.
PENTILT Tilt.
PENROTATION Rotation.
PENDRAWROTATION Draw rotation.
PENDRAWRANDOMNESS Draw randomness.
PENDRAWWHEELROTATION Draw wheel rotation.
PENDRAWWHEELPRESSURE Draw wheel pressure.
PENDRAWDISTANCE Draw distance.
PENFINGERWHEEL Finger wheel.
GeUserArea.MouseDragEnd()

Checks why the mouse drag ended. Allows to perform any undo operations needed if the user canceled the drag.

Return type:int
Returns:The mouse drag result:
MOUSEDRAGRESULT_ESCAPE Drag aborted.
MOUSEDRAGRESULT_FINISHED Drag finished.
MOUSEDRAGRESULT_CONTINUE Drag still in progress.
GeUserArea.GetBorderSize(type)

Retrieves the space required to draw a border.

Parameters:type (int) –

The border type:

BORDER_NONE No border.
BORDER_THIN_IN Thin border inward.
BORDER_THIN_OUT Thin border outward.
BORDER_IN Normal border inward.
BORDER_OUT Normal border outward.
BORDER_GROUP_IN Group border inside.
BORDER_GROUP_OUT Group border outside.
BORDER_OUT2 Outward border 2.
BORDER_OUT3 Outward border 3
BORDER_BLACK Thin black line.
BORDER_ACTIVE_1 Active border 1.
BORDER_ACTIVE_2 Active border 2.
BORDER_ACTIVE_3 Active border 3.
BORDER_ACTIVE_4 Active border 4.
BORDER_GROUP_TOP Border along the top.
BORDER_ROUND Border with round corners.
BORDER_SCHEME_EDIT Edit field border like the shortcut gadget for example.
BORDER_SCHEME_EDIT_NUMERIC Edit field border that is open to the right like the link field for example.
BORDER_OUT3l Outward border 3, open to the left.
BORDER_OUT3r Outward border 3, open to the right.
BORDER_MASK Masks out border type.
BORDER_WITH_TITLE_BOLD Display group title with bold font.
BORDER_WITH_TITLE Display group title in the border.
Return type:dict{l: int, t: int, r: int, b: int}
Returns:The space.