**THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED**

*On 21/07/2012 at 07:34, ***xxxxxxxx** wrote:

An option is to convert object point positions to camera space and calculate the DrawLine() start and end points there.

This example draws a '4' on the fourth point of an object. It always faces the camera and maintains a constant size when zooming and resizing viewports.

It currently works for the perspective and parallel cameras and the standard orthographic views (not Axonometric).

Let me know of any issues if you end up using it.

//------------------------------------------------

def RotateMatrix(m, rot) :

pos = m.off

scale = c4d.Vector(m.v1.GetLength(), m.v2.GetLength(), m.v3.GetLength())

m = utils.HPBToMatrix(rot)

m.off = pos

m.v1 = m.v1.GetNormalized() * scale.x

m.v2 = m.v2.GetNormalized() * scale.y

m.v3 = m.v3.GetNormalized() * scale.z

return m

def RotationOffset(proj) :

if proj is c4d.Pright: rotOffs = c4d.Vector(utils.Rad(90), 0, 0)

elif proj is c4d.Pleft: rotOffs = c4d.Vector(utils.Rad(-90), 0, 0)

elif proj is c4d.Ptop: rotOffs = c4d.Vector(0, utils.Rad(-90), 0)

elif proj is c4d.Pbottom: rotOffs = c4d.Vector(0, utils.Rad(90), 0)

elif proj is c4d.Pback: rotOffs = c4d.Vector(utils.Rad(180), 0, 0)

else: rotOffs = c4d.Vector(0, 0, 0)

return rotOffs

def ViewSize(doc, bd) :

frame = bd.GetFrame()

frameWdth = frame['cr']

frameHght = frame['cb']

rd = doc.GetActiveRenderData()

x_res = rd[c4d.RDATA_XRES_VIRTUAL]

y_res = rd[c4d.RDATA_YRES_VIRTUAL]

aspRat = y_res / x_res

if float(frameHght) / frameWdth >= aspRat:

viewSize = float(frameWdth)

else:

viewSize = (1.0 / aspRat) * frameHght

return viewSize

class PyDrawTest(plugins.TagData) :

def Init(self, tag) :

return True

def Draw(self, tag, op, bd, bh) :

doc = documents.GetActiveDocument()

camera = bd.GetSceneCamera(doc)

if camera is None: camera = bd.GetEditorCamera()

mCam = camera.GetMg()

bd.SetPen(c4d.Vector(1.0, 1.0, 1.0))

proj = bd.GetProjection()

if proj is not c4d.Pperspective and proj is not c4d.Pparallel:

mCam = RotateMatrix(mCam, RotationOffset(proj))

bd.SetMatrix_Matrix(camera, mCam, 4)

points = op.GetAllPoints()

pt_g = op.GetMg() * points[4]

pt = ~mCam * pt_g

defaultFlen = 36.0

viewSize = ViewSize(doc, bd)

scale = 1000.0

if proj is c4d.Pperspective:

zoom = camera[c4d.CAMERA_FOCUS] / defaultFlen * viewSize * 1000.0

else:

zoom = camera[c4d.CAMERA_ZOOM] * pt.z * viewSize

number = [[0, 0], [0, 20], [-8, 10], [4, 10]]

n = len(number)

for x in xrange(n - 1) :

offs1_x = number[x][0] * pt.z * scale / zoom

offs1_y = number[x][1] * pt.z * scale / zoom

offs2_x = number[x+1][0] * pt.z * scale / zoom

offs2_y = number[x+1][1] * pt.z * scale / zoom

p1 = c4d.Vector(pt.x + offs1_x, pt.y + offs1_y, pt.z)

p2 = c4d.Vector(pt.x + offs2_x, pt.y + offs2_y, pt.z)

bd.DrawLine(p1, p2, c4d.NOCLIP_Z)

return True

//------------------------------------------------