c4d.BaseDraw

class c4d.BaseDraw

This class represents a Cinema 4D window.

Warning

This type cannot be instantiated.

Methods Signatures

BaseDraw.__init__(self)

Initialize a new base draw.

BaseDraw.GetParameterData(self, id)

Get a new parameter object.

BaseDraw.GetFrameScreen(self)

Used in the Extended GL mode. This mode is not documented. See c4d_gl.h for definitions.

BaseDraw.HasCameraLink(self)

Indicates if the camera link is enabled.

BaseDraw.SetSceneCamera(self[, op, animate])

Sets a new scene camera. If op is None, the editor camera is used.

BaseDraw.GetSceneCamera(self, doc)

Returns the current scene camera from the passed document, or None if no scene camera is used.

BaseDraw.GetEditorCamera(self)

Returns the editor camera.

BaseDraw.GetDisplayFilter(self)

Returns the current display filter.

BaseDraw.GetEditState(self)

Get the edit state. This is a bit field derived from the edit state description flags in dbasedraw.h.

BaseDraw.IsViewOpen(self, doc)

Checks if the current tool can use the current SDS/Deformed editing state.

BaseDraw.InitializeView(self, doc, cam, editorsv)

Used after rendering into a framebuffer with different resolution than the editor view.

BaseDraw.InitClipbox(self, left, top, right, ...)

Used to render into a framebuffer with different resolution than the editor view.

BaseDraw.InitView(self, camera, op_m, sv, ...)

Used to render into a framebuffer with different resolution than the editor view.

BaseDraw.AddToPostPass(self, op, bh)

Adds the object op to DRAWPASS_XRAY.

BaseDraw.GetObjectColor(self, bh, op)

Returns the wireframe color in editor for the specified object.

BaseDraw.CheckColor(self, col)

Makes sure that a color has at least 15% difference to the background color.

BaseDraw.SetTransparency(self, trans)

Sets the transparency value for following polygons.

BaseDraw.GetTransparency(self)

Returns the current transparency value for polygons.

BaseDraw.PointInRange(self, p, x, y)

Returns True if the screen point (x,y) is within a hit range of the world point p, i.e. if the screen point is close to the world points projection on the screen.

BaseDraw.SetPen(self, col[, flags])

Sets the pen color for following drawing operations.

BaseDraw.SetPointSize(self, pointsize)

Sets the drawn point size.

BaseDraw.SimpleShade(self, p, n)

A quick shading algorithm that only takes the angle to the camera and a default light into account.

BaseDraw.ConvertColor(self, c)

Converts colors from document color profile to viewport color profile.

BaseDraw.ConvertColorReverse(self, c)

Converts colors from viewport color profile to document color profile.

BaseDraw.LineZOffset(self, offset)

Sets the current Z buffer offset.

BaseDraw.SetDepth(self, enable)

Enables/disables writing to the depth buffer.

BaseDraw.SetMatrix_Projection(self)

For internal use only.

BaseDraw.SetMatrix_Screen(self[, offset])

Sets the transformation matrix to screen coordinates, i.e. from (0, 0) to (width, height).

BaseDraw.SetMatrix_Camera(self)

Sets the transformation matrix to the camera system.

BaseDraw.SetMatrix_Matrix(self, op, mg[, zoffset])

Sets the transformation matrix to the given matrix mg.

BaseDraw.SetClipPlaneOffset(self, o)

Offsets the Viewport clipping planes by this offset.

BaseDraw.DrawPoint2D(self, p)

Draws a one-pixel point in the current pen color at p.

BaseDraw.DrawLine2D(self, p1, p2)

Draws a line in the current pen color between p1 and p2.

BaseDraw.DrawHandle2D(self, p[, type])

Draws a standard handle (orange dot) at p.

BaseDraw.DrawCircle2D(self, mx, my, rad)

Draws a circle in the current pen color with a radius of rad and the center at (mx, my).

BaseDraw.DrawLine(self, p1, p2, flags)

Draws a line in the current pen color between p1 and p2.

BaseDraw.DrawHandle(self, vp, type, flags)

Draws a standard handle (orange dot) at vp.

BaseDraw.DrawPoints(self, vp, vc[, colcnt, vn])

Draws an array of points with individual colors.

BaseDraw.DrawTexture(self, bmp, padr4, cadr, ...)

Draws a colored and shaded texture polygon using the points in padr4, the colors in cadr, the normals in vnadr and the UV coordinates in uvadr.

BaseDraw.DrawBox(self, m, size, col, wire)

Draws a box.

BaseDraw.DrawCircle(self, m)

Draws an ellipse in the current pen color.

BaseDraw.DrawArc(self, pos, radius, ...)

Draws an arc (section of a circle) in the current pen color at pos.

BaseDraw.DrawPolygon(self, p, f)

Draws a manually shaded triangle or quadrangle.

BaseDraw.DrawSphere(self, off, size, col, flags)

Draws a sphere at position off with size specified by the size vector in each direction and color specified by col.

BaseDraw.DrawArrayEnd(self)

Each DrawPolygon() puts the polygon into an internal array and draws the polygons when the array is full or an Viewport state changes (e.g. the matrix). With this method you can force this operation.

BaseDraw.DrawPolygonObject(self, bh, op, flags[, ...])

Draws a polygon object into the view.

BaseDraw.DrawObject(self, bh, op, flags, ...)

Draws a polygon object into the view.

BaseDraw.GetReductionMode(self)

Gets the reduction mode of the base draw.

BaseDraw.GetDrawPass(self)

Gets the current drawpass.

BaseDraw.GetHighlightPassColor(self, bh, lineObject)

Returns the color in which the object has to be drawn in the highlight pass.

BaseDraw.SetLightList(self, mode)

Sets the lighting used by the draw functions.

BaseDraw.InitUndo(self, doc)

Called before a change is made to the view to add the old setting to the undo buffer for the view.

BaseDraw.DoUndo(self, doc)

Performs an undo operation in the view.

BaseDraw.SetDrawParam(self, id, data)

Sets draw parameters.

BaseDraw.GetDrawParam(self, id)

Gets draw parameters.

BaseDraw.TestBreak(self)

Checks for thread breaks in the draw.

BaseDraw.GetEditorWindow(self)

Get the editor window of the BaseDraw.

BaseDraw.SetTexture(self, bm, tile, ...)

Set a texture used by the vertex buffer.

BaseDraw.GetGridStep(self)

Gets the grid spacing and the transparency value of the minor grid that fade when the user zoom in or out with dynamic grid.

BaseDraw.GetViewMatrix(self, n)

Gets the view matrix.

BaseDraw.DrawHUDText(self, x, y, txt)

Draws 2D text into the viewport in the style of the HUD.

BaseDraw.DrawMultipleHUDText(self, texts)

Draws many 2D text into the viewport at once.

BaseDraw.IsMarkedAsGPURenderer(self)

Checks if the view is marked as GPU Renderer.

BaseDraw.IsGPURenderer(self)

Checks if the view is running the GPU Renderer.

Inheritance

Parent Class:

Methods Documentation

BaseDraw.__init__(self)

Initialize a new base draw.

New in version R17.053.

Note

Useful for situations when there is no base draw available. It is used for instance in Mograph’s Camera shader.

BaseDraw.GetParameterData(self, id)

Get a new parameter object.

Parameters

id (int) – A parameter ID. See the dbasedraw.h description file.

Return type

Any

Returns

The parameter data for id. The type depends on the id.

BaseDraw.GetFrameScreen(self)

Used in the Extended GL mode. This mode is not documented. See c4d_gl.h for definitions.

Return type

Optional[Dict[cl: int, ct: int, cr: int, cb: int]]

Returns

A dict or None.

Indicates if the camera link is enabled.

Return type

bool

Returns

True if a scene camera is used, and False if the editor camera is used.

BaseDraw.SetSceneCamera(self, op=None, animate=False)

Sets a new scene camera. If op is None, the editor camera is used.

Parameters
  • op (Optional[c4d.BaseObject]) – The new camera.

  • animate (bool) – Private.

BaseDraw.GetSceneCamera(self, doc)

Returns the current scene camera from the passed document, or None if no scene camera is used.

Parameters

doc (Optional[c4d.documents.BaseDocument]) – The document to get the scene camera from.

Return type

c4d.BaseObject

Returns

The scene camera.

BaseDraw.GetEditorCamera(self)

Returns the editor camera.

Return type

c4d.BaseObject

Returns

The editor camera. Guaranteed to never be None.

BaseDraw.GetDisplayFilter(self)
Returns the current display filter.
This is a bit field derived from the DISPLAYFILTER values.

Note

To set the display filter use the description flags with GeListNode.__setitem__() or C4DAtom.SetParameter().

For instance the following script switches the Filter “Subdivision Surface”.

bd = doc.GetActiveBaseDraw()
displayFilter = bd.GetDisplayFilter()

if displayFilter & c4d.DISPLAYFILTER_HYPERNURBS:
    bd[c4d.DISPLAYFILTER_HYPERNURBS] = False
    print("Switched Off Subdivision Surface Display Filter")
else:
    bd[c4d.DISPLAYFILTER_HYPERNURBS] = True
    print("Switched On Subdivision Surface Display Filter")

bd.Message(c4d.MSG_CHANGE)
c4d.EventAdd()

Note the difference between the filters “Subdivision Surface” and “SDS Mesh”.

Return type

int

Returns

A bit field with the following flags:

DISPLAYFILTER_NONE

None.

DISPLAYFILTER_NULLOBJECT

Null.

DISPLAYFILTER_POLYGON

Polygon.

DISPLAYFILTER_SPLINE

Spline.

DISPLAYFILTER_GENERATOR

Generator.

DISPLAYFILTER_HYPERNURBS

Subdivision Surface.

DISPLAYFILTER_UNUSED1

Unused.

DISPLAYFILTER_DEFORMER

Deformer.

DISPLAYFILTER_CAMERA

Camera.

DISPLAYFILTER_LIGHT

Light.

DISPLAYFILTER_SCENE

Scene.

DISPLAYFILTER_PARTICLE

Particle.

DISPLAYFILTER_OTHER

Other.

DISPLAYFILTER_UNUSED2

New in version S22: Unused.

DISPLAYFILTER_GRID

Grid.

DISPLAYFILTER_HORIZON

Horizon.

DISPLAYFILTER_WORLDAXIS

World axis.

DISPLAYFILTER_BOUNDS

Bounding-box.

DISPLAYFILTER_HUD

HUD.

DISPLAYFILTER_SDS

HN mesh.

DISPLAYFILTER_HIGHLIGHTING

Highlighting.

DISPLAYFILTER_MULTIAXIS

Multi-select axis.

DISPLAYFILTER_OBJECTHANDLES

Highlight handles.

DISPLAYFILTER_HANDLEBANDS

Axis bands.

DISPLAYFILTER_SDSCAGE

HN cage.

DISPLAYFILTER_NGONLINES

N-gon lines.

DISPLAYFILTER_JOINT

Joint objects.

DISPLAYFILTER_OBJECTHIGHLIGHTING

Private.

DISPLAYFILTER_GUIDELINES

Axis Guidelines.

DISPLAYFILTER_POI

Navigation cross.

DISPLAYFILTER_GRADIENT

Gradient.

DISPLAYFILTER_BASEGRID

Base grid.

DISPLAYFILTER_HANDLES

Handles.

DISPLAYFILTER_HAIR

New in version S22: Hair.

DISPLAYFILTER_FIELD

New in version S22: Field.

BaseDraw.GetEditState(self)

Get the edit state. This is a bit field derived from the edit state description flags in dbasedraw.h.

Note

To set the display filter use the description flags with GeListNode.__setitem__() or C4DAtom.SetParameter().

Return type

int

Returns

A bit field with the following flags:

DISPLAYEDITSTATE_NONE

None.

DISPLAYEDITSTATE_SDS

SDS edit state.

DISPLAYEDITSTATE_DEFORM

Deformed edit state.

DISPLAYEDITSTATE_DOCUMENT

Document edit state.

BaseDraw.IsViewOpen(self, doc)

Checks if the current tool can use the current SDS/Deformed editing state.

Parameters

doc (c4d.documents.BaseDocument) – The current document.

Return type

bool

Returns

True if the view is open, otherwise False.

BaseDraw.InitializeView(self, doc, cam, editorsv)

Used after rendering into a framebuffer with different resolution than the editor view.

Parameters
BaseDraw.InitClipbox(self, left, top, right, bottom, flags)

Used to render into a framebuffer with different resolution than the editor view.

Parameters
  • left (int) – Left coordinate of the framebuffer.

  • top (int) – Top coordinate of the framebuffer.

  • right (int) – Right coordinate of the framebuffer.

  • bottom (int) – Bottom coordinate of the framebuffer.

  • flags (int) –

    Flags:

    INIT_CLIPBOX_ADJUSTGLSIZE

    Adjust the size of the frame buffer.

BaseDraw.InitView(self, camera, op_m, sv, pix_x, pix_y, fitview)

Used to render into a framebuffer with different resolution than the editor view.

Parameters
  • camera (c4d.BaseContainer) – The camera’s container.

  • op_m (c4d.Matrix) – The camera’s matrix.

  • sv (float) – The frame’s ratio.

  • pix_x (float) – The frame’s X size.

  • pix_y (float) – The frame’s Y size.

  • fitview (bool) – Set this to True to fit the view.

BaseDraw.AddToPostPass(self, op, bh)

Adds the object op to DRAWPASS_XRAY.

def Draw(self, op, drawpass, bd, bh):
    if drawpass == c4d.DRAWPASS_OBJECT:
        bd.AddToPostPass(op, bh)
        ok = True
    elif drawpass == c4d.DRAWPASS_XRAY:
        ok = True

    if not ok:
        return c4d.DRAWRESULT_OK

The object in this example is drawn both in regular and X-ray passes.

Note

This example is only relevant to ObjectData plugins.

Parameters
Return type

bool

Returns

True if successful, otherwise False.

BaseDraw.GetObjectColor(self, bh, op)
Returns the wireframe color in editor for the specified object.
Some types of objects have certain colors.

Note

For polygon objects the main color is taken into account.

Parameters
Return type

c4d.Vector

Returns

The object color.

BaseDraw.CheckColor(self, col)

Makes sure that a color has at least 15% difference to the background color.

Parameters

col (c4d.Vector) – The original vector.

Return type

c4d.Vector

Returns

The new color, adjusted if needed.

BaseDraw.SetTransparency(self, trans)
Sets the transparency value for following polygons.
The range is 0 to 255, where 255 is 100% transparent.

Note

Use negative values for true transparencies and positive values for ‘dotted’ transparencies.

Parameters

trans (int) – The transparency.

BaseDraw.GetTransparency(self)
Returns the current transparency value for polygons.
The range is 0 to 255, where 255 is 100% transparent.

Note

Negative values are true transparencies and positive values are ‘dotted’ transparencies.

Return type

int

Returns

The transparency.

BaseDraw.PointInRange(self, p, x, y)

Returns True if the screen point (x,y) is within a hit range of the world point p, i.e. if the screen point is close to the world points projection on the screen.

Parameters
  • p (c4d.Vector) – A point in world space.

  • x (int) – Screen x coordinate.

  • y (int) – Screen y coordinate.

Return type

bool

Returns

True if the point is within range, otherwise True.

BaseDraw.SetPen(self, col, flags=0)

Sets the pen color for following drawing operations.

Parameters
  • col (c4d.Vector) – The new color.

  • flags (Optional[int]) –

    SET_PEN_USE_PROFILE_COLOR

    Set this flag if the color is already in the color space of the BaseDraw. Otherwise the color will be converted.

BaseDraw.SetPointSize(self, pointsize)

Sets the drawn point size.

Parameters

pointsize (float) – The new point size.

BaseDraw.SimpleShade(self, p, n)
A quick shading algorithm that only takes the angle to the camera and a default light into account.
You pass a point and a normal in world space and get back the intensity.

Note

Can be combined with DrawPolygon() to draw simple shaded polygons.

Parameters
Return type

float

Returns

The intensity of the light. Between 0 and 1.

BaseDraw.ConvertColor(self, c)

Converts colors from document color profile to viewport color profile.

Parameters

c (c4d.Vector) – The color to convert (document).

Return type

c4d.Vector

Returns

The converted color (viewport).

BaseDraw.ConvertColorReverse(self, c)

Converts colors from viewport color profile to document color profile.

Parameters

c (c4d.Vector) – The color to convert (viewport).

Return type

c4d.Vector

Returns

The converted color (document).

BaseDraw.LineZOffset(self, offset)
Sets the current Z buffer offset.
Use this to for example draw lines over shaded polygons in front of the screen.
A higher offset value means a higher draw priority in the Z buffer. For example:
  • shaded polygon (level 0)

  • unselected edges (level 2)

  • selected edges (level 4)

Note

This function only affects the new draw functions below it, i.e. DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), and DrawSphere().

Parameters

offset (int) – The new Z buffer offset.

BaseDraw.SetDepth(self, enable)

Enables/disables writing to the depth buffer.

Parameters

enable (bool) – True to enable depth buffer writing, otherwise False.

BaseDraw.SetMatrix_Projection(self)

For internal use only.

BaseDraw.SetMatrix_Screen(self, offset=- 1)

Sets the transformation matrix to screen coordinates, i.e. from (0, 0) to (width, height).

Note

This function only affects the new draw functions below it, i.e. DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), and DrawSphere().

Parameters

offset (int) –

Sets the current Z buffer offset.
Use this to for example draw lines over shaded polygons in front of the screen.
A higher zoffset value means a higher draw priority in the Z buffer. For example:
  • shaded polygon (level 0)

  • unselected edges (level 2)

  • selected edges (level 4)

BaseDraw.SetMatrix_Camera(self)

Sets the transformation matrix to the camera system.

Note

This function only affects the new draw functions below it, i.e. DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), and DrawSphere().

BaseDraw.SetMatrix_Matrix(self, op, mg, zoffset=NOTOK)
Sets the transformation matrix to the given matrix mg.
The matrix should transform coordinates passed to the draw functions into world coordinates.
Parameters
  • op (Optional[c4d.BaseObject]) – A scene object. If passed this is used to compare if the same object is still used.

  • mg (c4d.Matrix) – The new transformation matrix.

  • zoffset (int) –

    Sets the current Z buffer offset.

    Use this to for example draw lines over shaded polygons in front of the screen.
    A higher zoffset value means a higher draw priority in the Z buffer. For example:
    • shaded polygon (level 0)

    • unselected edges (level 2)

    • selected edges (level 4)

BaseDraw.SetClipPlaneOffset(self, o)

Offsets the Viewport clipping planes by this offset.

New in version R14.014.

Parameters

o (float) – The offset.

BaseDraw.DrawPoint2D(self, p)
Draws a one-pixel point in the current pen color at p.
The coordinates must be in screen space.

Note

Changes the matrix to screen with SetMatrix_Screen() prior to drawing.

Parameters

p (c4d.Vector) – A point.

BaseDraw.DrawLine2D(self, p1, p2)
Draws a line in the current pen color between p1 and p2.
The coordinates must be in screen space.

Note

Changes the matrix to screen with SetMatrix_Screen() prior to drawing.

Parameters
BaseDraw.DrawHandle2D(self, p, type=DRAWHANDLE_SMALL)
Draws a standard handle (orange dot) at p.
The coordinates must be in screen space.

Note

Changes the matrix to screen with SetMatrix_Screen() prior to drawing.

Parameters
  • p (c4d.Vector) – A point.

  • type (int) –

    The handle type. Possible values are:

    DRAWHANDLE_MINI

    Tiny point.

    DRAWHANDLE_SMALL

    Small point.

    DRAWHANDLE_MIDDLE

    Medium point.

    DRAWHANDLE_BIG

    Big point. Handle used by object generators and deformers.

    DRAWHANDLE_CUSTOM

    Custom handle.

    DRAWHANDLE_POINTSIZE

    Use the point size to draw the handle.

    DRAWHANDLE_SELPOINTSIZE

    Use the size of selected points to draw the handle.

BaseDraw.DrawCircle2D(self, mx, my, rad)
Draws a circle in the current pen color with a radius of rad and the center at (mx, my).
The coordinates must be in screen space.

Note

Changes the matrix to screen with SetMatrix_Screen() prior to drawing.

Parameters
  • mx (int) – Center x coordinate.

  • my (int) – Center y coordinate.

  • rad (float) – The radius.

BaseDraw.DrawLine(self, p1, p2, flags)
Draws a line in the current pen color between p1 and p2.
The coordinates must be in world space.
Parameters
  • p1 (c4d.Vector) – The start point.

  • p2 (c4d.Vector) – The end point.

  • flags (int) –

    Flags:

    NOCLIP_D

    Clip against the view border.

    NOCLIP_Z

    Z clipping.

BaseDraw.DrawHandle(self, vp, type, flags)
Draws a standard handle (orange dot) at vp.
The coordinates must be in world space.
Parameters
  • vp (c4d.Vector) – A point.

  • type (int) –

    The handle type. Valid types are:

    DRAWHANDLE_MINI

    Tiny point.

    DRAWHANDLE_SMALL

    Small point.

    DRAWHANDLE_MIDDLE

    Medium point.

    DRAWHANDLE_BIG

    Big point. Handle used by object generators and deformers.

    DRAWHANDLE_CUSTOM

    Custom handle.

    DRAWHANDLE_POINTSIZE

    Use the point size to draw the handle.

    DRAWHANDLE_SELPOINTSIZE

    Use the size of selected points to draw the handle.

  • flags (int) – Private, set to 0.

BaseDraw.DrawPoints(self, vp, vc, colcnt=0, vn=None)

Draws an array of points with individual colors.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters
  • vp (any) – An iteratable object with Vector as elements for the point coordinates.

  • vc (Optional[any]) –

    An iteratable object with floats as elements for the points color.

    Changed in version R18.057.

    Can be None.

  • colcnt (int) – The number of color elements, for example 3 for RGB.

  • vn (Optional[any]) –

    Reserved for future use.

    Changed in version R18.057.

    Can be None.

BaseDraw.DrawTexture(self, bmp, padr4, cadr, vnadr, uvadr, pntcnt, alphamode, flags)
Draws a colored and shaded texture polygon using the points in padr4, the colors in cadr, the normals in vnadr and the UV coordinates in uvadr.
Only a triangle or a quadrangle is accepted.
The colors are interpolated between the points and mutiplied with the texture color.
The shading is determined by SetLightList().

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Note

Due to Python object live time limitation, the flags DRAW_TEXTUREFLAGS_TEMPORARY is always set.

Parameters
  • bmp (c4d.bitmaps.BaseBitmap) – The texture to draw.

  • padr4 (List[c4d.Vector]) – An iteratable object with Vector as elements for the points coordinates.

  • cadr (List[c4d.Vector]) – An iteratable object with Vector as elements for the colors. Must have 4 items regardless of pntcnt.

  • vnadr (List[c4d.Vector]) – An iteratable object with Vector as elements for the point normals. Must have 4 items regardless of pntcnt.

  • uvadr (List[c4d.Vector]) – An iteratable object with Vector as elements for the UV coordinates. Must have 4 items regardless of pntcnt.

  • pntcnt (int) – The number of points in padr4. Must be either 3 (triangle) or 4 (quadrangle).

  • alphamode (int) –

    The alpha channel mode:

    DRAW_ALPHA_NONE

    No alpha.

    DRAW_ALPHA_INVERTED

    Generates inverted alpha.

    DRAW_ALPHA_NORMAL

    Generates alpha channel from the image’s alpha channel. If no alpha channel exists, the alpha value is set to 100%.

    DRAW_ALPHA_FROM_IMAGE

    Generates the alpha channel from the RGB image information.

    DRAW_ALPHA_NORMAL_FROM_IMAGE

    Generates the alpha channel from the image’s alpha channel. If no alpha channel exists, the alpha value is generated from the RGB image.

  • flags (int) –

    A combination of these flags:

    DRAW_TEXTUREFLAGS_NONE

    None.

    DRAW_TEXTUREFLAGS_COLOR_IMAGE_TO_LINEAR

    Converts the embedded color profile to linear color space.

    DRAW_TEXTUREFLAGS_COLOR_SRGV_TO_LINEAR

    Converts from sRGB color space to linear color space.

    DRAW_TEXTUREFLAGS_IMAGE_TO_SRGB

    Converts the embedded color profile to sRGB color space.

    DRAW_TEXTUREFLAGS_COLOR_LINEAR_TO_SRGB

    Converts from linear color space to sRGB color space.

    DRAW_TEXTUREFLAGS_COLOR_CORRECTION_MASK

    Color correction mask.

    DRAW_TEXTUREFLAGS_USE_PROFILE_COLOR

    Use profile color.

    DRAW_TEXTUREFLAGS_ALLOW_FLOATINGPOINT

    Allow floating point textures (if supported).

    DRAW_TEXTUREFLAGS_TILE

    Allow tiling.

    DRAW_TEXTUREFLAGS_TEMPORARY

    Texture is a temporary object.

    DRAW_TEXTUREFLAGS_INTERPOLATION_NEAREST

    Nearest texture interpolation.

    DRAW_TEXTUREFLAGS_INTERPOLATION_LINEAR

    Linear texture interpolation.

    DRAW_TEXTUREFLAGS_INTERPOLATION_LINEAR_MIPMAP

    MIP map texture interpolation.

    DRAW_TEXTUREFLAGS_INTERPOLATION_MASK

    Texture interpolation mask.

BaseDraw.DrawBox(self, m, size, col, wire)
Draws a box.
The eight points of the box are defined as:
p = [c4d.Vector() for x in range(8)]
p[0] = c4d.Vector(-size, -size, -size)
p[1] = c4d.Vector( size, -size, -size)
p[2] = c4d.Vector( size, -size,  size)
p[3] = c4d.Vector(-size, -size,  size)
p[4] = c4d.Vector(-size,  size, -size)
p[5] = c4d.Vector( size,  size, -size)
p[6] = c4d.Vector( size,  size,  size)
p[7] = c4d.Vector(-size,  size,  size)

To get arbitrary cubic forms, set size to 0.5 and multiply the vectors in the matrix by the length.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters
  • m (c4d.Matrix) – A matrix describing the box.

  • size (float) – The size of the box.

  • col (c4d.Vector) – The color of the box.

  • wire (bool) – If this is True a wireframe is drawn.

BaseDraw.DrawCircle(self, m)
Draws an ellipse in the current pen color.
The ellipse is specified by the matrix m, where m.v1 and m.v2 are the axis vectors and m.off is the center position. (m.v3 is not used.)

The coordinates must be in world space.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters

m (c4d.Matrix) – A matrix describing the circle.

BaseDraw.DrawArc(self, pos, radius, angle_start, angle_end, subdiv=32, flags=0)
Draws an arc (section of a circle) in the current pen color at pos.
The coordinates must be in screen space.

New in version R14.014.

Parameters
  • pos (c4d.Vector) – Position of the rectangle that defines the arc.

  • radius (float) – The radius.

  • angle_start (float) – Start of the angle in radians.

  • angle_end (float) – End of the angle in radians.

  • subdiv (int) – The range between angle_start and angle_end is divided into subdiv line segments.

  • flags (int) –

    New in version R16.021.

    Flags:

    NOCLIP_D

    Clip against the view border.

    NOCLIP_Z

    Z clipping.

BaseDraw.DrawPolygon(self, p, f)
Draws a manually shaded triangle or quadrangle.
The corner points are given as a list of Vectors in p, and the corner colors as a corresponding list of Vectors in f.
p = ( c4d.Vector(0,0,0), c4d.Vector(100,0,0), c4d.Vector(50,100,0) )
f = ( c4d.Vector(1,0,0), c4d.Vector(0,0,1), c4d.Vector(0,1,0) )
bd.DrawPolygon(p, f)

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters
BaseDraw.DrawSphere(self, off, size, col, flags)

Draws a sphere at position off with size specified by the size vector in each direction and color specified by col.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters
  • off (c4d.Vector) – Position coordinate.

  • size (c4d.Vector) – Sphere size.

  • col (c4d.Vector) – The color.

  • flags (int) –

    Flags:

    NOCLIP_D

    Clip against the view border.

    NOCLIP_Z

    Z clipping.

BaseDraw.DrawArrayEnd(self)

Each DrawPolygon() puts the polygon into an internal array and draws the polygons when the array is full or an Viewport state changes (e.g. the matrix). With this method you can force this operation.

BaseDraw.DrawPolygonObject(self, bh, op, flags, parent=None, col=Vector(0.5))

Draws a polygon object into the view.

Parameters
  • bh (c4d.plugins.BaseDrawHelp) – Needs to be passed along.

  • op (c4d.BaseObject) – The object.

  • flags (int) –

    Flags:

    DRAWOBJECT_NONE

    None.

    DRAWOBJECT_FORCELINES

    Force wireframe display, independent of view settings.

    DRAWOBJECT_NOBACKCULL

    Force no backface culling, independent of view settings.

    DRAWOBJECT_LOCALMATRIX

    Object will be drawn relative to the currently processed object (used when called from the Draw() function in an object.

    DRAWOBJECT_EDITMODE

    Object is drawn in edit-mode style.

    DRAWOBJECT_FORCEBASE

    The draw call is only executed for the base class, and thus not for the instanciated object, if passed to BaseDraw.DrawObject() and the object type is an instance of either Opoint or Opolygon. This way, a draw call can be invoked from points/polygons derived object without running into a recursion.

    DRAWOBJECT_FORCEPOINTS

    Force points display.

    DRAWOBJECT_NO_EOGL

    No Extended OpenGL.

    DRAWOBJECT_USE_OBJECT_COLOR

    Use the object’s color.

    DRAWOBJECT_USE_CUSTOM_COLOR

    Use a custom color.

    DRAWOBJECT_XRAY_ON

    Enables X-Ray mode.

    DRAWOBJECT_XRAY_OFF

    Disables X-Ray mode.

    DRAWOBJECT_IMMEDIATELY

    Draws an object immediately. Usually all objects are collected in a Z-depth sorted list before drawing. This flag is used for objects which are immediately deleted after drawing.

    DRAWOBJECT_Z_OFFSET

    Do not change the Z offset.

    DRAWOBJECT_PRIVATE_ANY

    Private.

  • parent (Optional[c4d.BaseObject]) –

    New in version R21.

    This is used for the viewport filter.
    Take the Floor object for example, it displays a polygon object in the viewport. If parent is set to None the drawn polygon is considered by the viewport filter.
    If the Floor object has been passed to parent the Floor object is considered by the viewport filter instead.

  • col (c4d.Vector) –

    New in version R21.

    The object’s color.

BaseDraw.DrawObject(self, bh, op, flags, drawpass, parent, col=Vector(0.5))

Draws a polygon object into the view.

Parameters
  • bh (c4d.plugins.BaseDrawHelp) – Needs to be passed along.

  • op (c4d.BaseObject) – The object.

  • flags (int) –

    Flags:

    DRAWOBJECT_NONE

    None.

    DRAWOBJECT_FORCELINES

    Force wireframe display, independent of view settings.

    DRAWOBJECT_NOBACKCULL

    Force no backface culling, independent of view settings.

    DRAWOBJECT_LOCALMATRIX

    Object will be drawn relative to the currently processed object (used when called from the Draw() function in an object.

    DRAWOBJECT_EDITMODE

    Object is drawn in edit-mode style.

    DRAWOBJECT_FORCEBASE

    The draw call is only executed for the base class, and thus not for the instanciated object, if passed to BaseDraw.DrawObject() and the object type is an instance of either Opoint or Opolygon. This way, a draw call can be invoked from points/polygons derived object without running into a recursion.

    DRAWOBJECT_FORCEPOINTS

    Force points display.

    DRAWOBJECT_NO_EOGL

    No Extended OpenGL.

    DRAWOBJECT_USE_OBJECT_COLOR

    Use the object’s color.

    DRAWOBJECT_USE_CUSTOM_COLOR

    Use a custom color.

    DRAWOBJECT_XRAY_ON

    Enables X-Ray mode.

    DRAWOBJECT_XRAY_OFF

    Disables X-Ray mode.

    DRAWOBJECT_IMMEDIATELY

    Draws an object immediately. Usually all objects are collected in a Z-depth sorted list before drawing. This flag is used for objects which are immediately deleted after drawing.

    DRAWOBJECT_Z_OFFSET

    Do not change the Z offset.

    DRAWOBJECT_PRIVATE_ANY

    Private.

  • drawpass (int) –

    Drawpass:

    DRAWPASS_OBJECT

    Object pass.

    DRAWPASS_BOX

    Box pass.

    DRAWPASS_HANDLES

    Handle pass.

    DRAWPASS_HIGHLIGHTS

    Highlights pass.

    DRAWPASS_XRAY

    X-Ray pass.

  • parent (Optional[c4d.BaseObject]) – The parent object, can be None.

  • col (c4d.Vector) –

    New in version R21.

    The object’s color.

BaseDraw.GetReductionMode(self)

Gets the reduction mode of the base draw.

Return type

bool

Returns

True on success, otherwise False.

BaseDraw.GetDrawPass(self)

Gets the current drawpass.

New in version R14.041.

Return type

int

Returns

One of the following flags:

DRAWPASS_OBJECT

Object pass.

DRAWPASS_BOX

Box pass.

DRAWPASS_HANDLES

Handle pass.

DRAWPASS_HIGHLIGHTS

Highlights pass.

DRAWPASS_XRAY

X-Ray pass.

BaseDraw.GetHighlightPassColor(self, bh, lineObject)

Returns the color in which the object has to be drawn in the highlight pass.

New in version R19.

Note

This function should only be called in the highlight pass.

Parameters
  • bh (c4d.plugins.BaseDrawHelp) – The base draw help.

  • lineObject (int) – Must be set to True if the object is a line object.

Return type

Optional[c4d.Vector]

Returns

The highlight color, or None if drawing the object can be skipped.

BaseDraw.SetLightList(self, mode)

Sets the lighting used by the draw functions.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Note

This method only affects the new 3D drawing methods, i.e. DrawLine(), DrawHandle(), DrawTexture(), DrawCircle(), DrawBox(), DrawPolygon() and DrawSphere().

Parameters

mode (int) –

The lighting mode:

BDRAW_SETLIGHTLIST_NOLIGHTS

No lights.

BDRAW_SETLIGHTLIST_SCENELIGHTS

Scene lights.

BDRAW_SETLIGHTLIST_QUICKSHADING

Quick shading.

Return type

bool

Returns

True on success, otherwise False.

BaseDraw.InitUndo(self, doc)

Called before a change is made to the view to add the old setting to the undo buffer for the view.

Note

This undo buffer is separate from the normal undo buffer.

Parameters

doc (c4d.documents.BaseDocument) – The view’s document.

BaseDraw.DoUndo(self, doc)

Performs an undo operation in the view.

Note

This is the same as the user selecting Undo View from within Cinema 4D.

Parameters

doc (c4d.documents.BaseDocument) – The view’s document.

BaseDraw.SetDrawParam(self, id, data)

Sets draw parameters.

Note

The coordinates must be in the space defined by SetMatrix_Screen(), SetMatrix_Camera() or SetMatrix_Matrix().

Parameters
  • id (int) – Parameter ID.

  • data (any) – Depends on the parameter ID.

BaseDraw.GetDrawParam(self, id)

Gets draw parameters.

Parameters

id (int) – Parameter ID.

Return type

Any

Returns

Depends on the parameter ID.

BaseDraw.TestBreak(self)

Checks for thread breaks in the draw.

Return type

bool

Returns

True if a stopping condition has occurred, otherwise False.

BaseDraw.GetEditorWindow(self)

Get the editor window of the BaseDraw.

Return type

c4d.gui.EditorWindow

Returns

The editor window of the base draw.

BaseDraw.SetTexture(self, bm, tile, alphamode, flags)

Set a texture used by the vertex buffer.

Parameters
  • bm (c4d.bitmaps.BaseBitmap) – The texture’s bitmap.

  • tile (bool) – Enable tiling.

  • alphamode (int) –

    Alpha channel mode:

    DRAW_ALPHA_NONE

    No alpha.

    DRAW_ALPHA_INVERTED

    Generates inverted alpha.

    DRAW_ALPHA_NORMAL

    Generates alpha channel from the image’s alpha channel. If no alpha channel exists, the alpha value is set to 100%.

    DRAW_ALPHA_FROM_IMAGE

    Generates the alpha channel from the RGB image information.

    DRAW_ALPHA_NORMAL_FROM_IMAGE

    Generates the alpha channel from the image’s alpha channel. If no alpha channel exists, the alpha value is generated from the RGB image.

  • flags (int) – Private, set to 0.

BaseDraw.GetGridStep(self)

Gets the grid spacing and the transparency value of the minor grid that fade when the user zoom in or out with dynamic grid.

New in version R14.014.

Return type

Tuple[float, float]

Returns

The workplane grid spacing and the transparency value of the minor grid.

BaseDraw.GetViewMatrix(self, n)

Gets the view matrix.

New in version R14.014.

Parameters

n (int) –

View matrix to get:

DRAW_GET_VIEWMATRIX_PROJECTION

Projection matrix.

DRAW_GET_VIEWMATRIX_PROJECTION_LARGE_Z

Projection matrix without consideration of the set clipping planes. The following values for near and far clipping are used instead: near=`1`, far=`100000` for perspective projection and near=`-1000000`, far=`1000000` for other projection types.

DRAW_GET_VIEWMATRIX_INV_CAMERA

Inverse camera matrix.

DRAW_GET_VIEWMATRIX_MODELVIEW_PROJECTION

Projection*View*Model matrix. Slow.

Return type

Tuple[16*float]

Returns

The view matrix (4x4 matrix).

BaseDraw.DrawHUDText(self, x, y, txt)

Draws 2D text into the viewport in the style of the HUD.

New in version R18.020.

Parameters
  • x (int) – The left X coordinate to draw the text at.

  • y (int) – The upper Y coordinate to draw the text at.

  • txt (str) – The text to draw.

BaseDraw.DrawMultipleHUDText(self, texts)

Draws many 2D text into the viewport at once.

New in version R18.020.

Parameters

texts (List[Dict['_txt': str, '_position': c4d.Vector]]) – The list of text entries and their screen space positions to draw to the HUD.

BaseDraw.IsMarkedAsGPURenderer(self)

Checks if the view is marked as GPU Renderer.

New in version R19.024.

Return type

bool

Returns

True if the view is marked to run the GPU Renderer, otherwise False.

BaseDraw.IsGPURenderer(self)

Checks if the view is running the GPU Renderer.

New in version R19.024.

Return type

bool

Returns

True if the view is running the GPU renderer, otherwise False.