BaseView / BaseDraw Manual


A BaseView object represents a viewport window. Such a BaseView can be obtained from the active BaseDocument to get information on the viewport window. The class BaseDraw is based on BaseView. It can be used to draw something in a viewport window via a "Draw" function.

It is only allowed to draw into the viewport inside a "Draw" function. See Draw Manual.


The BaseDraw windows used to display the active BaseDocument can be accessed with:

See BaseDocument Editor Windows.

Such a BaseDraw can be used to access the scene camera.

// This example accesses the active BaseDraw to get its camera.
// Then it moves the active object into the view of that camera.
BaseDraw* const baseDraw = doc->GetActiveBaseDraw();
if (baseDraw == nullptr)
return maxon::IllegalArgumentError(MAXON_SOURCE_LOCATION);
BaseObject* const cameraObject = baseDraw->GetEditorCamera();
// move active object into the camera view
const Matrix cameraMatrix = cameraObject->GetMg();
Matrix targetPosition = activeObject->GetMg(); = + (900.0 * cameraMatrix.sqmat.v3);
Definition: c4d_basedraw.h:754
BaseObject * GetEditorCamera(void)
Definition: c4d_basedraw.h:874
Definition: c4d_baseobject.h:225
Matrix GetMg() const
Definition: c4d_baseobject.h:482
Definition: memoryallocationbase.h:67
const char * doc
Definition: pyerrors.h:226
V off
The translation vector.
Definition: matrix.h:263
SqrMat3< V > sqmat
The 3×3 matrix for rotation, scale and shear.
Definition: matrix.h:266


The viewport windows are redrawn if something in the active document changed:

  • EventAdd(): Informs Cinema 4D that something in the active document changed. DrawViews() will be called.
  • DrawViews(): Manually triggers the scene execution and a viewport redraw. Typically only used directly in ToolData based tools.

See also Core Messages Manual and Cinema 4D Threads Manual.


The parameters of a given BaseDraw are accessed as usual with C4DAtom::GetParameter() and C4DAtom::SetParameter(). The parameter IDs are defined in dbasedraw.h

// This example enables the display of polygon normals.
// scale normal size
const Float newScale = oldScale * 2.0;
GeData GetParameterData(Int32 id)
Bool SetParameter(const DescID &id, const GeData &t_data, DESCFLAGS_SET flags)
Float GetFloat(void) const
Definition: c4d_gedata.h:439
Definition: dbasedraw.h:44
Definition: dbasedraw.h:30
Definition: dbasedraw.h:69
maxon::Float Float
Definition: ge_sys_math.h:66
// This example changes the projection type and display mode.
const DescID projectionID { BASEDRAW_DATA_PROJECTION };
const Int32 projectionType = BASEDRAW_PROJECTION_FRONT;
baseDraw->SetParameter(projectionID, projectionType, DESCFLAGS_SET::NONE);
baseDraw->SetParameter(displayID, displayType, DESCFLAGS_SET::NONE);
Definition: lib_description.h:330
Definition: dbasedraw.h:247
Definition: dbasedraw.h:26
Definition: dbasedraw.h:231
Definition: dbasedraw.h:40
maxon::Int32 Int32
Definition: ge_sys_math.h:60

A BaseDraw defines also certain display filters that decide what element types are displayed in the viewport windows.

To edit the filter settings use the parameters defined in dbasedraw.h
// This example checks if the given BaseObject is visible in the active editor view.
BaseDraw* const bd = doc->GetActiveBaseDraw();
if (bd == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
const DISPLAYFILTER filter = bd->GetDisplayFilter();
const Bool displayFilter = CheckDisplayFilter(object, filter);
// check editor visibility
const Bool editorVisibiliy = CheckEditorVisibility(object);
// check if the object is visible in the viewport
if (displayFilter && editorVisibiliy)
ApplicationOutput("The object is visible in the Editor"_s);
ApplicationOutput("The object is not visible in the Editor"_s);
Bool CheckDisplayFilter(BaseObject *op, DISPLAYFILTER filter)
Bool CheckEditorVisibility(BaseObject *op)
DISPLAYFILTER GetDisplayFilter() const
Definition: c4d_basedraw.h:1594
maxon::Bool Bool
Definition: ge_sys_math.h:55
Definition: ge_prepass.h:4537
#define ApplicationOutput(formatString,...)
Definition: debugdiagnostics.h:210
// This example switches the filter setting
// of the SDS filter.
const DISPLAYFILTER filter = baseDraw->GetDisplayFilter();
// switch filter for SDS
Definition: dbasedraw.h:189
Subdivision Surface.


A viewport window with planar projection can be rotated:

// This example restores the rotation of all editor windows.
const Int32 count = doc->GetBaseDrawCount();
for (Int32 i = 0; i < count; ++i)
BaseDraw* const baseDraw = doc->GetBaseDraw(i);
if (baseDraw == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
Py_ssize_t i
Definition: abstract.h:645
Py_ssize_t count
Definition: abstract.h:640
void InitUndo(BaseDocument *doc)
Definition: c4d_basedraw.h:1484
void SetPlanarRotation(Float r)
Definition: c4d_basedraw.h:335


A viewport window with a perspective projection displays the scene from the point of view of a camera. This camera is defined using an object. This can be a scene camera, a scene object or the editor camera.

See also CameraObject Manual.

// This example accesses or sets the scene camera.
// get the BaseDraw
BaseDraw* const bd = doc->GetActiveBaseDraw();
if (bd == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
// check if a scene camera is used
if (bd->HasCameraLink())
// get scene camera and print the name
BaseObject* const cam = bd->GetSceneCamera(doc);
if (cam != nullptr)
ApplicationOutput("Camera Object: " + cam->GetName());
// create a new camera object
if (camera == nullptr)
return maxon::OutOfMemoryError(MAXON_SOURCE_LOCATION);
doc->InsertObject(camera, nullptr, nullptr);
// use this camera as the scene camera
Bool HasCameraLink(void)
Definition: c4d_basedraw.h:828
void SetSceneCamera(BaseObject *op, Bool animate=false)
Definition: c4d_basedraw.h:842
BaseObject * GetSceneCamera(const BaseDocument *doc)
Definition: c4d_basedraw.h:835
String GetName() const
Definition: c4d_baselist.h:2363
static BaseObject * Alloc(Int32 type)
#define Ocamera
Camera - CameraObject.
Definition: ge_prepass.h:1030

Scene Elements

The viewport also displays a background and some global light settings. Both the background and the global seetings are defines using scene elements.

// This example accesses the sky object and
// environment object from the given BaseDraw.
BaseObject* const envObject = baseDraw->GetEnvironmentObject();
if (envObject)
GeData data;
const Vector color = data.GetVector();
ApplicationOutput("Environment Color: " + String::VectorToString(color));
// check the used sky object
BaseObject* const skyObject = baseDraw->GetSkyObject();
if (skyObject)
BaseTag* const tag = skyObject->GetTag(Ttexture);
if (tag)
GeData data;
C4DAtom* const atom = data.GetLinkAtom(doc);
BaseList2D* const material = static_cast<BaseList2D*>(atom);
if (material)
ApplicationOutput("Material on Sky: " + material->GetName());
BaseObject * GetSkyObject() const
Definition: c4d_basedraw.h:856
BaseObject * GetEnvironmentObject() const
Definition: c4d_basedraw.h:849
Definition: c4d_baselist.h:2190
BaseTag * GetTag(Int32 type, Int32 nr=0)
Definition: c4d_baseobject.h:685
Definition: c4d_basetag.h:48
Definition: c4d_baselist.h:1377
Bool GetParameter(const DescID &id, GeData &t_data, DESCFLAGS_GET flags)
Definition: c4d_gedata.h:83
const Vector & GetVector(void) const
Definition: c4d_gedata.h:451
C4DAtomGoal * GetLinkAtom(const BaseDocument *doc, Int32 instanceof=0) const
static String VectorToString(const Vector32 &v, Int32 nnk=-1)
Definition: c4d_string.h:571
#define atom
Definition: graminit.h:72
#define Ttexture
Texture - TextureTag.
Definition: ge_prepass.h:1384
Definition: oenvironment.h:6
Definition: ttexture.h:29

GPU Renderer

The GPU renderer of Cinema 4D can render inside a given BaseDraw window.

// This example checks if the given BaseDraw is marked as
// a GPU render view and is currently using the GPU renderer.
if (baseDraw->IsMarkedAsGPURenderer())
if (baseDraw->IsGPURenderer())
ApplicationOutput("BaseDraw is rendering using the GPU renderer.");
Bool IsGPURenderer()
Definition: c4d_basedraw.h:1806
Bool IsMarkedAsGPURenderer()
Definition: c4d_basedraw.h:1799


Inside a "Draw" function one can use the following functions to draw into the viewport windows. See Draw Manual.

It is not allowed to draw in any other context.

While drawing one should check if the drawing thread has been aborted:

// This example tests if the current drawing operation should be aborted.
return false;
// check if all pointers are valid
if (node == nullptr || doc == nullptr || bd == nullptr || bh == nullptr)
// check if the drawing operation should be aborted
if (bd->TestBreak())
return true;
PyCompilerFlags * flags
Definition: ast.h:14
Definition: c4d_basedocument.h:498
Definition: c4d_basedraw.h:40
Bool TestBreak()
Definition: c4d_basedraw.h:1727
Definition: c4d_basedocument.h:51
Definition: c4d_thread.h:28
Definition: ge_prepass.h:3308
#define iferr_scope_handler
Definition: resultbase.h:1392
#define iferr_throw(ERR)
Definition: resultbase.h:1528
Definition: node.h:10

Drawing Pass

The viewport is drawn in several passes. One should check if the drawing operation is needed in the current pass. This is especially important for ObjectData::Draw().


Several parameters configure the drawing operations that follow.

The parameters are:

At the end of the drawing operation these parameters have to be restored.
// This example changes the line width, draws a line and resets the old value.
// store and set line width
const GeData oldLineWidth = bd->GetDrawParam(DRAW_PARAMETER_LINEWIDTH);
// draw lines
bd->SetPen(Vector { 1.0, 0.0, 0.0 });
bd->DrawLine(Vector { 0, 0, 0 }, Vector { 100, 100, 0 }, NOCLIP_D);
// reset parameter
void DrawLine(const Vector &p1, const Vector &p2, Int32 flags)
Definition: c4d_basedraw.h:1215
void SetDrawParam(Int32 id, const GeData &data)
Definition: c4d_basedraw.h:1503
GeData GetDrawParam(Int32 id) const
Definition: c4d_basedraw.h:1511
void SetPen(const Vector &col, Int32 flags=0)
Definition: c4d_basedraw.h:987
Float Line width in pixels. (OpenGL only.)
Definition: c4d_basedraw.h:1516
#define NOCLIP_D
Clip against the view border.
Definition: c4d_basedraw.h:1136


The draw settings configure the drawing operations that follow.

The color used with BaseDraw::SetPen() may be obtained with GetViewColor(). See also Colors.
// This example draws some points with random color and size.
bd->SetMatrix_Matrix(nullptr, Matrix(), 6);
Random rnd;
for (Int32 i = 0; i < 100; ++i)
// set random color
const Float r = rnd.Get01();
const Float g = rnd.Get01();
const Float b = rnd.Get01();
const Vector color { r, g, b };
// set random size
const Float size = rnd.Get01() * 10.0;
// draw point with custom size
const Vector pos { i* 10.0, 0.0, 0.0 };
void SetPointSize(Float pointsize)
Definition: c4d_basedraw.h:993
void SetMatrix_Matrix(BaseObject *op, const Matrix &mg)
Definition: c4d_basedraw.h:1107
void DrawHandle(const Vector &vp, DRAWHANDLE type, Int32 flags)
Definition: c4d_basedraw.h:1188
Definition: c4d_tools.h:812
Float Get01(void)
Py_ssize_t size
Definition: bytesobject.h:86
void Py_ssize_t * pos
Definition: dictobject.h:50
maxon::Mat3< maxon::Vector64 > Matrix
Definition: ge_math.h:167
Custom handle.
const char const char grammar * g
Definition: parsetok.h:52

The light list defines what lights should influence the shading on 3D drawing operations. Typically used to disable lights.

Transparency settings for polygon drawing are defined with:



A drawing operation may be performed in screen, camera or world space. Before any drawing operation the operation space must be defined.

// This example draws some points in various spaces.
// draw something in screen space
const Vector screenPos { 100, 100.0, 0.0 };
bd->DrawHandle(screenPos, DRAWHANDLE::BIG, 0);
// draw something in camera space
const Vector camPos { 0.0 }; // center of non-perspective camera
bd->DrawHandle(camPos, DRAWHANDLE::BIG, 0);
// draw something in world space
const Vector worldPos { 100.0, 100.0, 100.0 };
bd->SetMatrix_Matrix(nullptr, Matrix());
bd->DrawHandle(worldPos, DRAWHANDLE::BIG, 0);
void SetMatrix_Camera()
Definition: c4d_basedraw.h:1095
void SetMatrix_Screen()
Definition: c4d_basedraw.h:1073
Handle used by object generators and deformers.

2D Drawing Operations

These functions perform drawing operations in 2D space:

To calculate screen space coordinates see Transformation.
// This example draws a 2D line, circle and point.
const Vector center { 100, 100, 0 };
const Vector tangentPoint { 150, 100, 0 };
// draw line and circle
bd->DrawLine2D(center, tangentPoint);
bd->DrawCircle2D((Int32)center.x, (Int32)center.y, tangentPoint.x - center.x);
// draw point
void DrawPoint2D(const Vector &p)
Definition: c4d_basedraw.h:1150
void DrawCircle2D(Int32 mx, Int32 my, Float rad)
Definition: c4d_basedraw.h:1175
void DrawLine2D(const Vector &p1, const Vector &p2)
Definition: c4d_basedraw.h:1158
maxon::Vec3< maxon::Float64, 1 > Vector
Definition: ge_math.h:145

Text can easily be drawn with:

These functions are typically used with a scene hook.
// This example draws two text boxes in the viewport in a scene hook.
const DRAWPASS pass = bd->GetDrawPass();
// check if the current pass is the object pass with inverted highlight flag
HUDTextEntry entryA;
entryA._txt = "This is the first entry";
entryA._position = Vector { 200, 220, 0 };
hudEntries.Append(entryA) iferr_return;
HUDTextEntry entryB;
entryB._txt = "This is the second entry";
entryB._position = Vector { 200, 260, 0 };
hudEntries.Append(entryB) iferr_return;
void SetTransparency(Int32 trans)
Definition: c4d_basedraw.h:968
DRAWPASS GetDrawPass() const
Definition: c4d_basedraw.h:1619
void DrawMultipleHUDText(const maxon::BaseArray< HUDTextEntry > &texts)
Definition: c4d_basedraw.h:1769
Class structure to hold HUD Text for BaseDraw::DrawMultipleHUDText().
Definition: c4d_basedraw.h:247
Vector _position
The screen space position for the text.
Definition: c4d_basedraw.h:252
String _txt
The text to draw to the HUD.
Definition: c4d_basedraw.h:251
Definition: basearray.h:412
Definition: basearray.h:677
Definition: ge_prepass.h:3505
Object pass.
Inverted highlight pass.
#define iferr_return
Definition: resultbase.h:1465

General Drawing Operations

Depending on the current transformation matrix these operations can draw in 2D or 3D space.

The z-buffer is configured with:

These clipping flags used with 3D drawing operations:

  • NOCLIP_D: Clip against the viewport window.
  • NOCLIP_Z: Clip against near and far plane.

The drawing operations are:

// This example fills a GeClipMap.
// The internal BaseBitmap is used to draw the content to the screen.
if (clipMap)
clipMap->Init(100, 50, 32);
// fill background
clipMap->SetColor(255, 0, 0, 64);
clipMap->FillRect(0, 0, 100, 50);
// draw text
clipMap->SetColor(0, 0, 0, 255);
clipMap->TextAt(0, 11, "Hello World");
const BaseBitmap* const bitmap = clipMap->GetBitmap();
if (bitmap)
// draw texture in screen space
bd->DrawTexture(bitmap, positions.GetFirst(), colors.GetFirst(), normals.GetFirst(), uvcoords.GetFirst(), 4, alpha, texture);
Definition: ge_autoptr.h:37
Definition: c4d_basebitmap.h:428
void DrawTexture(const BaseBitmap *bmp, const Vector *padr4, const Vector *cadr, const Vector *vnadr, const Vector *uvadr, Int32 pntcnt, DRAW_ALPHA alphamode, DRAW_TEXTUREFLAGS flags)
Definition: c4d_basedraw.h:1253
Definition: ge_prepass.h:2969
Generates the alpha channel from the RGB image information.
Definition: ge_prepass.h:2982

Each BaseDraw::DrawPolygon() puts the polygon into an internal array. The drawing of this array can be triggered with:

A simple shading value is often used with BaseDraw::DrawPoly() and BaseDraw::DrawPolygon():

// This example shades four vertices and uses the
// calculated colors with BaseDraw::DrawPolygon().
// base color
const Vector color { 1.0, 0.0, 0.0 };
// calculate shades
colors[0] = color * bd->SimpleShade(vertice[0], normals[0]);
colors[1] = color * bd->SimpleShade(vertice[1], normals[1]);
colors[2] = color * bd->SimpleShade(vertice[2], normals[2]);
colors[3] = color * bd->SimpleShade(vertice[3], normals[3]);
// draw in object space
const Matrix& mg = bh->GetMg();
bd->SetMatrix_Matrix(op, mg);
// no additional shading
// set transparency
// draw polygon
bd->DrawPolygon(vertice, colors, true);
const Matrix & GetMg(void)
Definition: c4d_basedraw.h:85
void SetLightList(Int32 mode)
Definition: c4d_basedraw.h:1007
Float SimpleShade(const Vector &p, const Vector &n)
Definition: c4d_basedraw.h:1721
void DrawPolygon(const Vector *p, const Vector *f, Bool quad)
Definition: c4d_basedraw.h:1298
No lights.
Definition: c4d_basedraw.h:1011
PyObject * op
Definition: object.h:520


Complete polygon objects can be drawn with:

// This example re-draws the currently active polygon object in a ObjectData::Draw() function.
BaseDocument* const doc = bd->GetDocument();
// check if the current pass is the object pass
const Bool docSet = doc != nullptr;
const Bool isObjectPass = drawpass == DRAWPASS::OBJECT;
if (docSet && isObjectPass)
// get the active object
BaseObject* const activeObject = doc->GetActiveObject();
// check if the active object is not the host object itself
// and if it is a polygon object
const Bool activeObjectSet = activeObject != nullptr;
const Bool activeObjectIsNotOp = activeObject != op;
if (activeObjectSet && activeObjectIsNotOp)
if (activeObject->IsInstanceOf(Opolygon))
// draw the object
bd->SetMatrix_Matrix(nullptr, Matrix());
bd->DrawObject(bh, activeObject, DRAWOBJECT::NONE, drawpass, nullptr);
DRAWRESULT DrawObject(BaseDrawHelp *bh, BaseObject *op, DRAWOBJECT flags, DRAWPASS drawpass, BaseObject *parent=nullptr, const Vector &col=Vector(.5))
Definition: c4d_basedraw.h:1345
Bool IsInstanceOf(Int32 id) const
Definition: c4d_baselist.h:1418
BaseDocument * GetDocument()
Definition: c4d_baselist.h:1960
@ OK
Something was drawn.
#define Opolygon
Polygon - PolygonObject.
Definition: ge_prepass.h:1026

Line Strip

The line strip functions allow to easily draw line paths:

// This example draws a random path composed of several lines.
Random randomGen;
// start position
Vector pos(0);
// init
const GeData oldLineWidth = bd->GetDrawParam(DRAW_PARAMETER_LINEWIDTH);
bd->SetMatrix_Matrix(nullptr, Matrix());
// draw random lines
for (Int32 i = 0; i < 100; ++i)
// get random color
const Float r = randomGen.Get01();
const Float g = randomGen.Get01();
const Float b = randomGen.Get01();
const Vector color { r, g, b };
bd->LineStrip(pos, color, NOCLIP_Z);
// apply random offset
const Float x = randomGen.Get01() * 100;
const Float y = randomGen.Get01() * 100;
const Float z = randomGen.Get01() * 100;
pos += Vector(x, y, z);
// reset parameter
void LineStripBegin()
Definition: c4d_basedraw.h:1377
void LineStripEnd()
Finishes line strips started with LineStripBegin().
Definition: c4d_basedraw.h:1382
void LineStrip(const Vector &vp, const Vector &vc, Int32 flags)
Definition: c4d_basedraw.h:1391
PyObject * x
Definition: bytesobject.h:38
#define NOCLIP_Z
Z clipping.
Definition: c4d_basedraw.h:1137

XOR Lines

XOR lines are used with selection tools in the viewport. Typically one should use the LassoSelection class instead.

These functions have been marked as deprecated.

See also EditorWindow::DrawXORLine().

// This example draws a XOR line in ToolData::MouseInput().
// check if the view can be initialized
bd->DrawXORPolyLine(point, 2);
const DRAWFLAGS flags =
win->DrawXORLine((Int32)point[0], (Int32)point[1], (Int32)point[2], (Int32)point[3]);
Bool DrawViews(DRAWFLAGS flags, BaseDraw *bd=nullptr)
Bool InitDrawXORPolyLine()
Definition: c4d_basedraw.h:1404
void DrawXORPolyLine(const Float32 *p, Int32 cnt)
Definition: c4d_basedraw.h:1441
void FreeDrawXORPolyLine()
Definition: c4d_basedraw.h:1411
void BeginDrawXORPolyLine()
Definition: c4d_basedraw.h:1448
void EndDrawXORPolyLine(Bool blit)
Definition: c4d_basedraw.h:1456
Definition: ge_prepass.h:2820
Ignore all animation.
In move.
Only redraw the active view.
Synchronous call.


Colors can be obtained and converted with:

// This example gets the object color for the object itself in ObjectData::Draw().
// This color is then used to draw a circle.
const Vector color = bd->GetObjectColor(bh, op);
bd->SetMatrix_Matrix(nullptr, Matrix());
Matrix circleSettings = bh->GetMg();
circleSettings.sqmat.v1 *= 200.0;
circleSettings.sqmat.v2 *= 200.0;
circleSettings.sqmat.v3 *= 200.0;
Vector GetObjectColor(const BaseDrawHelp *bh, BaseObject *op, Bool lines=false, Bool usedInBaseDraw=true, Int instanceIndex=0) const
Definition: c4d_basedraw.h:954
void DrawCircle(const Matrix &m)
Definition: c4d_basedraw.h:1259


The dimensions of a viewport window are accessed with:

// This example prints the frame size of the given BaseDraw.
// PrintFrameSize() is a custom utility function.
Int32 cl, ct, cr, cb;
// frame size
baseDraw->GetFrame(&cl, &ct, &cr, &cb);
PrintFrameSize(cl, ct, cr, cb);
// safe frame
baseDraw->GetSafeFrame(&cl, &ct, &cr, &cb);
PrintFrameSize(cl, ct, cr, cb);
void GetSafeFrame(Int32 *cl, Int32 *ct, Int32 *cr, Int32 *cb)
void GetFrame(Int32 *cl, Int32 *ct, Int32 *cr, Int32 *cb)


These functions get and change the stereo settings for the given viewport window:


A viewport window can display the scene using orthogonal or perspective projection:


The following functions allow to transform a given point between world, screen and camera space:

// This example draws a circle around the position of the active object.
const BaseObject* const object = doc->GetActiveObject();
if (object)
const Vector worldSpacePos = object->GetMg().off;
const Vector screenSpacePos = bd->WS(worldSpacePos);
bd->DrawCircle2D((Int32)screenSpacePos.x, (Int32)screenSpacePos.y, 100);
Vector WS(const Vector &p) const
Definition: c4d_basedraw.h:409
T y
Definition: vec.h:40
T x
Definition: vec.h:39
// This example picks an object in the viewport within a ToolData:MouseInput() function.
// The distance of the picked object is obtained from the C4DObjectList and used
// with BaseView::SW() to get the world space position.
const Int32 xpos = (Int32)x;
const Int32 ypos = (Int32)y;
const Bool res = ViewportSelect::PickObject(bd, doc, xpos, ypos, 1,
if (res && (list->GetCount() > 0))
const Float distance = list->GetZ(0);
const Vector worldSpacePos = bd->SW(Vector(x, y, distance));
ApplicationOutput("World Space Hit Point: " + String::VectorToString(worldSpacePos));
const char * m
Definition: abstract.h:692
Vector SW(const Vector &p) const
Definition: c4d_basedraw.h:417
static Bool PickObject(BaseDraw *bd, BaseDocument *doc, Int32 x, Int32 y, Int32 rad, VIEWPORT_PICK_FLAGS flags, LassoSelection *ls, C4DObjectList *list, maxon::SquareMatrix4d *m=nullptr, Int32 *sampleLocation=nullptr)
Py_UCS4 * res
Definition: unicodeobject.h:1113
PyWideStringList * list
Definition: initconfig.h:447
Definition: matrix4d.h:13

Also sizes can be transformed:

  • BaseView::PW_S(): Returns the size in world units for a single pixel at the given Z-depth.
  • BaseView::WP_S(): Returns the size in pixels for a single world unit at the given Z-depth.
  • BaseView::PW_W(): Returns the size in world units for a single pixel at the given screen space position.
  • BaseView::WP_W(): Returns the size in screen space pixels for a single world unit at world position.

These 3D projection functions are typically used to handle mouse input in tools:

// This example moves an object on the base plane in a ToolData::MouseInput() function.
Int32 err = 0;
const Vector pos = bd->ProjectPointOnPlane(Vector(0), Vector(0, 1, 0), positionX, positionY, &err);
if (err == 0)
// place object
Matrix mg = object->GetMg(); = pos;
// update managers and viewport
Bool GeSyncMessage(Int32 messageid, Int32 destid=0, UInt p1=0, UInt p2=0)
Vector ProjectPointOnPlane(const Vector &p, const Vector &v, Float mouse_x, Float mouse_y, Int32 *err=nullptr)
The user moved something in the editor window. Managers should update things like position fields.
Definition: ge_prepass.h:2784

Testing and Clipping

The following tests can be performed:

// This example draws a 2D circle for each point of the given polygon object.
// The object is only handled if its bounding box is visible in the viewport.
// A circle is only drawn if the point is inside the viewport window.
// get polygon object properties
const Matrix mg = polyObject->GetMg();
const Vector bbox = polyObject->GetMp();
const Vector rad = polyObject->GetRad();
// test if the poly object is visible at all
if (bd->TestClipping3D(bbox, rad, mg, nullptr, nullptr))
// set pen color
Vector color(0.6, 0.6, 0.6);
color = bd->CheckColor(color);
// points
const Vector* const points = polyObject->GetPointR();
const Int32 pointCount = polyObject->GetPointCount();
// get each point
for (Int32 i = 0; i < pointCount; ++i)
const Vector point = mg * points[i];
const Vector screenSpacePos = bd->WS(point);
// check each point
if (bd->TestPoint(screenSpacePos.x, screenSpacePos.y))
// draw circle for each point
bd->DrawCircle2D(SAFEINT32(screenSpacePos.x), SAFEINT32(screenSpacePos.y), 10.0f);
Vector CheckColor(const Vector &col)
Definition: c4d_basedraw.h:961
Bool TestClipping3D(const Vector &mp, const Vector &rad, const Matrix &mg, Bool *clip2d, Bool *clipz)
Bool TestPoint(Float x, Float y)
Definition: c4d_basedraw.h:348
Int32 SAFEINT32(Float32 x)
Definition: apibasemath.h:266

A given line define by two points can be clipped:

A view can use near- and far-clipping:


A BaseDraw has its own undo buffer that stores changes:

// This example restores the rotation of all editor windows.
const Int32 count = doc->GetBaseDrawCount();
for (Int32 i = 0; i < count; ++i)
BaseDraw* const baseDraw = doc->GetBaseDraw(i);
if (baseDraw == nullptr)
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);


Further functions are:

// This example accesses the Drawport statistics of the given BaseDraw
// and prints them to the console window.
// get draw statistics
maxon::DataDictionary stats;
if (!baseDraw->GetDrawStatistics(stats))
return maxon::UnexpectedError(MAXON_SOURCE_LOCATION);
for (const auto& data : stats)
const maxon::Data key = data.first.GetCopy() iferr_return;
const maxon::Data value = data.second.GetCopy() iferr_return;
const maxon::DataType type = value.GetType();
ApplicationOutput("Key: @, Value: @ (@)", key, value, type);
PyObject * value
Definition: abstract.h:715
PyObject * key
Definition: abstract.h:289
Bool GetDrawStatistics(maxon::DataDictionary &statistics) const
Definition: c4d_basedraw.h:1627
Definition: datatypebase.h:1199
Definition: datatypebase.h:772
PyObject ** type
Definition: pycore_pyerrors.h:34


BaseDrawHelp is a utility class that contains useful information. It is mostly used in the context of ObjectData::Draw(). An instance is typically handed over as an argument but can also be created on demand:

The BaseDrawHelp object provides access to these properties:

Information on the BaseObject that is supposed to be drawn:

A BaseObject may be drawn with a specific display mode as defined in Tdisplay.h.

// This example draws a given polygon object using a BaseDrawHelp in ObjectData::Draw().
// allocate BaseDrawHelp
if (bhelp == nullptr)
// get the current display options
BaseContainer displayOptions = bh->GetDisplay();
// set mode to "Wire"
// set display options
// get Matrix from original BaseDrawHelp object
const Matrix originalMatrix = bh->GetMg();
// draw an object
bd->DrawObject(bhelp, object, flags, DRAWPASS::OBJECT, nullptr, Vector(1.0, 0, 0));
// free BaseDrawHelp
Definition: c4d_basecontainer.h:47
void SetInt32(Int32 id, Int32 l)
Definition: c4d_basecontainer.h:505
BaseContainer GetDisplay(void)
Definition: c4d_basedraw.h:103
BaseDocument * GetDocument(void)
Definition: c4d_basedraw.h:73
static void Free(BaseDrawHelp *&p)
void SetDisplay(BaseContainer *bc)
Definition: c4d_basedraw.h:109
void SetMg(const Matrix &mg)
Definition: c4d_basedraw.h:97
static BaseDrawHelp * Alloc(BaseDraw *bd, BaseDocument *doc)
Definition: ge_prepass.h:4645
Use a custom color.
Disables X-Ray mode.
No Extended OpenGL.
There was an error while drawing.
Definition: tdisplay.h:6

Further Reading