This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com

c4d.BaseDraw – a BaseDraw class

This class represents a Cinema 4D window and cannot be instantiated.

The base class of many other classes.

class c4d.BaseDraw

SuperClass

BaseView

Methods

BaseDraw.GetParameterData(id)

The parameter data for id.

Return type:any
Returns:The data, depends on id. Can be None.
BaseDraw.GetFrameScreen()

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

dimension = bd.GetFrameScreen()
#dimension["cl"], dimension["ct"], dimension["cr"], dimension["cb"]
Return type:dict of int
Returns:The dimension.

Indicates if the camera link is enabled.

Return type:bool
Returns:True if a scene camera is used and False is the editor camera is used.
BaseDraw.SetSceneCamera([op=None[, animate=False]])

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

Parameters:
  • op (BaseObject or None) – The new camera.
  • animate (bool) – False
BaseDraw.GetSceneCamera(doc)

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

Parameter:doc (BaseDocument) – The document to get the scene camera from.
Return type:BaseObject
Returns:The scene camera or None.
BaseDraw.GetEditorCamera()

Returns the editor camera.

Return type:BaseObject
Returns:The scene camera, cannot be None.
BaseDraw.GetEditState()

Returns the current edit state.

Return type:

int

Returns:

The bit:

DISPLAY_EDITSTATE_SDS

SDS edit state.

DISPLAY_EDITSTATE_DEFORM

Deformed edit state.

BaseDraw.GetDisplayFilter()

Returns the current display filter.

Return type:

int

Returns:

The bit:

DISPLAYFILTER_NULL

Null Objects.

DISPLAYFILTER_POLYGON

Polygon Objects.

DISPLAYFILTER_SPLINE

Spline Objects.

DISPLAYFILTER_GENERATOR

Generator.

DISPLAYFILTER_HYPERNURBS

HyperNurbs.

DISPLAYFILTER_BONE

Bones.

DISPLAYFILTER_DEFORMER

Deformers.

DISPLAYFILTER_CAMERA

Cameras.

DISPLAYFILTER_LIGHT

Lights.

DISPLAYFILTER_SCENE

Scene objects.

DISPLAYFILTER_PARTICLE

Particle objects.

DISPLAYFILTER_OTHER

Other objects.

DISPLAYFILTER_GRID

Grid.

BaseDraw.IsViewOpen(doc)

Check ifs the view of the passed Document is open.

Parameter:doc (BaseDocument) – The document.
Return type:int
Returns:True if the view is open.
BaseDraw.InitClipbox(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) –
    INIT_CLIPBOX_ADJUSTGLSIZE Adjust the size of the frame buffer.
BaseDraw.InitView(camera, op_m, sv, pix_x, pix_y, fitview)

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

Parameters:
  • camera (BaseContainer) – The camera container.
  • op_m (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.InitializeView(doc, cam, editorsv)

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

Parameters:
  • doc (BaseDocument) – The view’s document.
  • cam (:class:`BaseObject <c4d.BaseObject>) – The view’s camera.
  • editorsv (bool) – Set this True to retain the view’s ratio.
BaseDraw.AddToPostPass(op, bh)

Adds the object op to DRAWPASS_XRAY. For example:

class MyObject(plugins.ObjectData):

     def Draw(self, op, drawpass, bd, bh):
         ok = False #initialize

         if drawpass==plugins.DRAWPASS_OBJECT:
             bd.AddToPostBass(op, bh)
             ok = True
         elif drawpass==plugins.DRAWPASS_XRAY:
             ok = True

         return ok

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

Parameters:
  • op (BaseObject) – The object to add to the X-ray pass.
  • bh (BaseDrawHelper) – The current base draw helper.
Return type:

bool

Returns:

True on success.

BaseDraw.GetObjectColor(bh, op)

Returns the wireframe color in editor for the specified object. Some types of objects have certain colors. For polygon objects the main color is taken into account.

Parameters:
  • bh (BaseDrawHelper) – The current base draw helper.
  • op (BaseObject) – The object.
Return type:

Vector

Returns:

The color.

BaseDraw.CheckColor(col)

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

Parameter:col (Vector) – The original color.
Return type:Vector
Returns:The new color, adjusted if needed.
BaseDraw.ZBufAvailable()

Indicates if the current display mode has a Z-buffer. For example 2D wireframe has no Z-buffer.

Return type:bool
Returns:True if the current display mode uses a Z-buffer, otherwise False.
BaseDraw.GetTransparency()

Returns the current transparency value for polygons. The range is 0 to 255, where 255 is 100% transparent.

Return type:int
Returns:The transparency.
BaseDraw.SetTransparency(trans)

Sets the transparency value for following polygons. The range is 0 to 255, where 255 is 100% transparent.

Parameter:trans (int) – The transparency.
BaseDraw.PointInRange(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 (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 False.

BaseDraw.SetPen(col)

Set the color of the pen

Parameter:color (Vector) – The color.
BaseDraw.SimpleShade(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. Can be combined with BaseDraw.Polygon3D() to draw simple shaded polygons.

Parameters:
  • p (Vector) – A point in world space.
  • n (Vector) – A normal in world space.
Return type:

float

Returns:

The intensity of the light. Between 0 and 1.

BaseDraw.Point2D(p)

Draws a one-pixel point in the current pen color at p. The coordinates must be in screen space.

Parameter:p (Vector) – The position of the point.
BaseDraw.Line2D(p1, p2)

Draws a line in the current pen color between p1 and p2. The coordinates must be in screen space.

Parameters:
  • p1 (Vector) – The start pointer.
  • p2 (Vector) – The end point.
BaseDraw.Handle2D(pos[, handle=HANDLE_SMALL])

Draws a standard handle (orange dot) at p. The coordinates must be in screen space.

Parameters:
  • start (Vector) – The start position of the line.
  • handle (int) –

    The handle type.

    HANDLE_MINI Tiny point.
    HANDLE_SMALL Small point.
    HANDLE_MIDDLE Medium point..
    HANDLE_BIG Handle used by object generators and deformers.
BaseDraw.Circle2D(x, y, 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.

Parameters:
  • x (int) – Center x coordinate.
  • y (int) – Center y coordinate.
  • rad (float) – Radius
BaseDraw.LineCS(p1, p2[, offset=False])

Note

When you use this method, please pass the arg names for backward compatibility. The order and count of arguments might change.

A faster way to draw lots of lines from camera space. The line is defined by the coordinates p1 and p2.

Parameters:
  • p1 (Vector) – The start pointer.
  • p2 (Vector) – The end point.
  • offset (bool) – If this is True the line is drawn a bit in front of the regular Z depth. This is used e.g. in Polygon mode where the lines have to be moved towards the camera so that they’re still drawn (otherwise the Z inprecision can make them invisible).
BaseDraw.Point3D(p)

Draws a one-pixel point in the current pen color at p. The coordinates must be in world space.

Parameter:p (Vector) – The position of the point.
BaseDraw.Line3D(p1, p2)

Draws a line in the current pen color between p1 and p2. The coordinates must be in world space.

Parameters:
  • p1 – The start point.
  • p1 (Vector) – The end point.
BaseDraw.Handle3D(p, type

Draws a line in the current pen color between p1 and p2. The coordinates must be in world space.

Parameters:
  • p1 (Vector) – The start point.
  • type (int) – The end point.
BaseDraw.Handle3D(pos[, handle=HANDLE_SMALL])

Draws a handle dot. You can set the color with BaseDraw.set_pen().

Parameters:
  • start (Vector) – The start position of the line.
  • handle (int) –

    The handle type.

    HANDLE_MINI Tiny point.
    HANDLE_SMALL Small point.
    HANDLE_MIDDLE Medium point..
    HANDLE_BIG Handle used by object generators and deformers.
BaseDraw.Circle3D(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 isn’t used.) The coordinates must be in world space.

Parameter:m (Matrix) – A matrix describing the circle.
BaseDraw.Box3D(m, size, col)

Draws a Box in 3D. The eight points of the box are defined as:

p = (None) * 8
p[0] = m * Vector(-size, -size, -size)
p[1] = m * Vector( size, -size, -size)
p[2] = m * Vector( size, -size,  size)
p[3] = m * Vector(-size, -size,  size)
p[4] = m * Vector(-size,  size, -size)
p[5] = m * Vector( size,  size, -size)
p[6] = m * Vector( size,  size,  size)
p[7] = m * Vector(-size,  size,  size)
Parameters:
  • m (Matrix) – A matrix describing the box.
  • size (float) – The size of the box.
  • rad (int) – The color of the box.
BaseDraw.Polygon3D(p, f, quad)

Draws a manually shaded triangle or quadrangle. The corner points are given as an list of Vectors in p, and the corner colors as a corresponding list of Vectors in f. If quad is False there should be three elements in each list, otherwise four. The colors are interpolated between the corners. Example:

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.Polygon3D(p, f, False)
Parameters:
  • p (list of Vector) – A list of points.
  • f (list of type Vector) – A list of points.
  • quad (bool) – True means the arrays have four elements, False means they have three.
BaseDraw.LineZOffset(col)

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(0); Unselected Edges(2); Selected Edges(4)

Parameter:offset (int) – The new Z buffer offset.
BaseDraw.SetMatrix_Projection(col)
Just for internal use.
BaseDraw.SetMatrix_Screen()

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. LineNew(), LineStrip(), DrawHandle(), DrawPoly(), DrawTexture(), CircleNew(), Box3DNew(), PolygonNew() and DrawSphere().

BaseDraw.SetMatrix_Camera()

Sets the transformation matrix to the camera system.

Note

This function only affects the new draw functions below it, i.e. LineNew(), LineStrip(), DrawHandle(), DrawPoly(), DrawTexture(), CircleNew(), Box3DNew(), PolygonNew() and DrawSphere().

BaseDraw.DrawHandle(vp, type, flags)

raws a standard handle (orange dot) at vp.

Parameters:
  • vp (Vector) – Point coordinate.
  • type (int) –

    The handle type.

    HANDLE_MINI Tiny point.
    HANDLE_SMALL Small point.
    HANDLE_MIDDLE Medium point..
    HANDLE_BIG Handle used by object generators and deformers.
  • flags (int) –

    The flags.

    NOCLIP_D Clip against the view border.
    NOCLIP_Z Z clipping.
BaseDraw.CircleNew(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 isn’t used.).

Note

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

BaseDraw.Box3DNew(m, size, col, wire)

Draws a box. The eight points of the box are defined as:

p = (None) * 8
p[0] = m * Vector(-size, -size, -size)
p[1] = m * Vector( size, -size, -size)
p[2] = m * Vector( size, -size,  size)
p[3] = m * Vector(-size, -size,  size)
p[4] = m * Vector(-size,  size, -size)
p[5] = m * Vector( size,  size, -size)
p[6] = m * Vector( size,  size,  size)
p[7] = m * 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 (Matrix) – A matrix describing the box.
  • size (float) – The size of the box.
  • col (Vector) – The color.
  • wire (bool) – If this is True a wireframe is drawn.
BaseDraw.DrawSphere(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 (Vector) – Position coordinate.
  • size (Vector) – Sphere size.
  • col (Vector) – The color.
  • flags (int) –
    NOCLIP_D Clip against the view border.
    NOCLIP_Z Z clipping.
BaseDraw.SetLightList(mode)

Sets the lighting used by the draw functions.

Parameter:mode (int) –

The light mode.

BDRAW_SETLIGHTLIST_NOLIGHTS No lights.
BDRAW_SETLIGHTLIST_SCENELIGHTS Scene lights.
BDRAW_SETLIGHTLIST_QUICKSHADING Quick shading.
BaseDraw.InitUndo(doc)

Called before a change is made to the view to add the old setting to the undo buffer for the view. (This undo buffer is separate from the normal undo buffer.)

BaseDraw.DoUndo(doc)

Performs an undo operation in the view. This is the same as the user selecting Undo View from within CINEMA 4D.

BaseDraw.SetDrawParam(id, data)

Sets draw parameters.

Parameters:
  • id (int) –

    Parameter ID.

    DRAW_PARAMETER_LINEWIDTH float Line width in pixels. (OpenGL only.)
    DRAW_PARAMETER_ALPHA_THRESHOLD float Alpha treshold. (Make sure to set old value back afterwards!)
    DRAW_PARAMETER_SETZ int Z buffer mode:
    DRAW_Z_LOWEREQUAL Normal mode.
    DRAW_Z_GREATER Reversed mode.
    DRAW_Z_ALWAYS Always mode.
  • data (any) – New parameter data.
BaseDraw.GetDrawParam(id)

Get draw parameters.

Parameter:id (int) –

Parameter ID.

DRAW_PARAMETER_LINEWIDTH float Line width in pixels. (OpenGL only.)
DRAW_PARAMETER_ALPHA_THRESHOLD float Alpha treshold. (Make sure to set old value back afterwards!)
DRAW_PARAMETER_SETZ int Z buffer mode:
DRAW_Z_LOWEREQUAL Normal mode.
DRAW_Z_GREATER Reversed mode.
DRAW_Z_ALWAYS Always mode.
Return type:any
Returns:Depends on id.
BaseDraw.TestBreak()

Checks for thread breaks in the draw.

Return type:bool:
Returns:True if if a stopping condition has occurred, otherwise False.
BaseDraw.GetEditorWindow()

Get the EditorWindow of the BaseDraw.

Return type:EditorWindow
Returns:The editor window.
BaseDraw.SetTexture(bmp, tile, alphamode)

Set a texture used by the vertex buffer.

Parameters:
  • bm (BaseBitmap) – The texture’s bitmap.
  • tile (bool) – Enable tiling.
  • alphamode (int) –

    Alpha channel mode:

    DRAW_ALPHA_NONE No alpha.
    DRAW_ALPHA_INVERTED Inverted alpha.
    DRAW_ALPHA_NORMAL Normal alpha.

Table Of Contents

This Page