ObjectData/Draw/DrawPolygonObject in XRay Mode

• On 15/02/2016 at 10:53, xxxxxxxx wrote:

Hello everybody,

i´d like to draw a PolygonObject in Xray mode into the viewport. Im able to draw the object, but just without xray.

def Draw(self, op, drawpass, bd, bh) :
if drawpass!=c4d.DRAWPASS_XRAY:
obj = MachCube(100, 75, 50)
bd.DrawPolygonObject(bh, obj, c4d.DRAWOBJECT_0)

return c4d.DRAWRESULT_OK

...

def MachCube(size_x, size_y, size_z) :
size = c4d.Vector()
size.x = size_x
size.y = size_y
size.z = size_z

cube = c4d.PolygonObject(8, 6)

pnts = [c4d.Vector() for x in xrange(8)]
pnts = c4d.Vector(-size.x/2, -size.y/2, -size.z/2)
pnts = c4d.Vector(-size.x/2,  size.y/2, -size.z/2)
pnts = c4d.Vector( size.x/2, -size.y/2, -size.z/2)
pnts = c4d.Vector( size.x/2,  size.y/2, -size.z/2)
pnts = c4d.Vector( size.x/2, -size.y/2,  size.z/2)
pnts = c4d.Vector( size.x/2,  size.y/2,  size.z/2)
pnts = c4d.Vector(-size.x/2, -size.y/2,  size.z/2)
pnts = c4d.Vector(-size.x/2,  size.y/2,  size.z/2)

plys = c4d.CPolygon(0,1,3,2), c4d.CPolygon(2,3,5,4), c4d.CPolygon(4,5,7,6), c4d.CPolygon(6,7,1,0), c4d.CPolygon(1,7,5,3), c4d.CPolygon(6,0,2,4)

cube.SetAllPoints(pnts)
for index, ply in enumerate(plys) : cube.SetPolygon(index, ply)

return cube

Is it possible to do?

Greetings
rown

• On 16/02/2016 at 03:07, xxxxxxxx wrote:

Hello,

It seems to work fine using DrawObject() and setting the ID_BASEOBJECT_XRAY parameter of the drawn object.

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

self._cube[c4d.ID_BASEOBJECT_XRAY] = op[c4d.ID_BASEOBJECT_XRAY]

bd.DrawObject(bh, self._cube, c4d.DRAWOBJECT_0, drawpass, op)

return c4d.DRAWRESULT_OK

Also it seems to be the best solution to store the geometry as a member of your class.

Best wishes,
Sebastian

• On 16/02/2016 at 07:27, xxxxxxxx wrote:

Hey Sebastian,

thx alot. I also tried to set the ID_BASEOBJECT_XRAY parameter yesterday. But I didnt try to let the object be a member. Thats the solution.

if drawpass!=c4d.DRAWPASS_XRAY:
self.cube[c4d.ID_BASEOBJECT_XRAY] = op[c4d.ID_BASEOBJECT_XRAY]
bd.DrawObject(bh, self.cube, c4d.DRAWOBJECT_0, drawpass, op)
c4d.DRAWRESULT_OK

One other question just for knowing. Why cant I draw a primitive object like c4d.BaseObject(c4d.Ocube)? At this point its not importaint to know, but it was noticed by me.

Thx and greetings
rown