Editor draw in a object plugin[SOLVED]

On 22/10/2014 at 13:15, xxxxxxxx wrote:

Does anyone have a sample object plugin they would be willing to share?
I'm using it to simply do what a null does (store children) but it has custom functions.

My issue is what it looks like in the editor. If I "include Onull" in the .res file, i can control parameters for what it should draw, but it doesn't work. Is it possible to use those draw parameters and get it to work?
If not, then just drawing a flat square would be fine. (it would need to scale and rotate with the op).

Thanks,
Joe

On 22/10/2014 at 17:54, xxxxxxxx wrote:

Hi Joe,

two month ago I used a gizmo box for doing somthing similar.
I´m not sure, if that helps.

  
  def Draw(self, node, drawpass, bd, bh) :   
  
      if drawpass==c4d.DRAWPASS_HANDLES:  
        
          data= node.GetDataInstance()  
          size= data.GetVector(10001)/2  
          mat = node.GetMg()  
          bd.SetMatrix_Matrix(None, mat)  
          box = c4d.Matrix()  
          box.v1 = box.v1 * size.x  
          box.v2 = box.v2 * size.y  
          box.v3 = box.v3 * size.z  
          bd.DrawBox(box, 1.0, c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEPOINT), True)  

Best wishes
Martin

On 23/10/2014 at 07:24, xxxxxxxx wrote:

That helps. Now, to make it another color when highlighted.. I want it to work the way a Null does. Black lines then white when highlighted/selected. Heres what I got.

	def Draw(self, op, drawpass, bd, bh) :
		
		if drawpass==c4d.DRAWPASS_HIGHLIGHTS:
			bd.SetPen(c4d.Vector(1,1,1))
			return c4d.DRAWRESULT_SKIP
  
		data= op.GetDataInstance()
		size= c4d.Vector(25,0,25)
		mat = op.GetMg()
		bd.SetMatrix_Matrix(None, mat)
		box = c4d.Matrix()
		box.v1 = box.v1 * size.x
		box.v2 = box.v2 * size.y
		box.v3 = box.v3 * size.z
		bd.SetPen(c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEBOX))
		bd.DrawBox(box, 1.0, c4d.GetViewColor(c4d.VIEWCOLOR_SHADEDWIRE), True)
		return c4d.DRAWRESULT_OK

On 23/10/2014 at 07:45, xxxxxxxx wrote:

Hello,

you can use IsActive() and IsHighlight() to find out if the current object is selected or highlighted.

Best wishes,
Sebastian

On 23/10/2014 at 11:08, xxxxxxxx wrote:

Right. I can get it to like "print "Highlighted"". So I know when it's highlighted, but how can I change the color of the basedraw? Do I have to redraw it? Or just somehow change the pen color..

Thanks.

On 23/10/2014 at 12:09, xxxxxxxx wrote:

Hi Joe,

you can use a custom color definition like:

  
  def Draw(self, node, drawpass, bd, bh) :   
        
      pencolor = c4d.Vector(0,0,0)  
  
      if bh.IsHighlight() :  
          pencolor = c4d.Vector(1,1,1)  
          print "highlight"  
  
      if bh.IsActive() :  
          pencolor = c4d.Vector(1,1,0)  
          print "active"  
  
      data= op.GetDataInstance()  
      size= c4d.Vector(25,0,25)  
      mat = op.GetMg()  
      bd.SetMatrix_Matrix(None, mat)  
      box = c4d.Matrix()  
      box.v1 = box.v1 * size.x  
      box.v2 = box.v2 * size.y  
      box.v3 = box.v3 * size.z  
      bd.DrawBox(box, 1.0, pencolor, True)  
  

or have a look at the c++ sdk
http://www.maxonexchange.de/sdk/Cinema4DR16SDK/html/group___v_i_e_w_c_o_l_o_r.html#ga59ce3d29b2ad9c9e57410cefd023adbb

Best wishes
Martin

On 23/10/2014 at 18:28, xxxxxxxx wrote:

Here's my code. If I have one object selected, I don't see the Active color, It appears as black. Highlight works though.

But, If I have multiple objects selected, they appear yellow (which is correct). Any ideas?

	def Draw(self, op, drawpass, bd, bh) :
		pencolor = c4d.Vector(0,0,0)
		if bh.IsHighlight() :
			pencolor = c4d.GetViewColor(c4d.VIEWCOLOR_OBJECTHIGHLIGHT)
  
		if bh.IsActive() :
			pencolor = c4d.GetViewColor(c4d.VIEWCOLOR_OBJECTSELECT)
  
		data= op.GetDataInstance()
		size= c4d.Vector(10,0,10)
		mat = op.GetMg()
		bd.SetMatrix_Matrix(None, mat)
		box = c4d.Matrix()
		box.v1 = box.v1 * size.x
		box.v2 = box.v2 * size.y
		box.v3 = box.v3 * size.z
		bd.DrawBox(box, 1.0, pencolor, True)
  
		return c4d.DRAWRESULT_OK

On 24/10/2014 at 02:47, xxxxxxxx wrote:

Hi Joe,

this works,
Just a better setup for the different cases with if and elif...
And you use the colors the user predefined in his preferences

  
      if drawpass==c4d.DRAWPASS_OBJECT:  
  
          data= node.GetDataInstance()  
          size= c4d.Vector(10,0,10)  
          mat = node.GetMg()  
          bd.SetMatrix_Matrix(None, mat)  
          box = c4d.Matrix()  
          box.v1 = box.v1 * size.x  
          box.v2 = box.v2 * size.y  
          box.v3 = box.v3 * size.z  
  
          if bh.IsHighlight() :  
              pencolor=c4d.GetViewColor(c4d.VIEWCOLOR_SELECTION_PREVIEW)  
          elif bh.IsActive() :  
              pencolor=c4d.GetViewColor(c4d.VIEWCOLOR_ACTIVEPOINT)  
          else:  
              pencolor=c4d.GetViewColor(c4d.VIEWCOLOR_INACTIVEPOINT)  
          bd.DrawBox(box, 1.0, pencolor, True)  

Best wishes
Martin

On 24/10/2014 at 05:58, xxxxxxxx wrote:

That did it! Thanks Martin