Object plugin and object color

On 20/08/2014 at 05:21, xxxxxxxx wrote:

I am using a Object plugin to create some object.
I like to give these objects a color using below code.
However, in a Object Plugin this is not working. Just the standard grey color and Use Color is Off.

In a tag plugin it is working.
Is it because I use a Object Plugin?

    def GetVirtualObjects(self, node, hierarchyhelp) :
        cube = c4d.BaseObject(c4d.Ocube)      
        cube.SetName("Cube with color")
        cube[c4d.ID_BASEOBJECT_USECOLOR] = 2                #2 = On 
        cube[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(1,0,0)
        return cube

On 21/08/2014 at 03:15, xxxxxxxx wrote:

When you register the object plugin you need to use the OBJECT_USECACHECOLOR flag in order for this to work.


On 21/08/2014 at 04:40, xxxxxxxx wrote:

Sorry, still not working.
I now use following registration code:

    plugins.RegisterObjectPlugin(id = PLUGIN_ID, 
                                 str         = pluginstr,
                                 g           = C4Doxelate,
                                 description = "c4dvox",               
                                 icon        = bmp,
                                 info        = c4d.OBJECT_GENERATOR | c4d.OBJECT_USECACHECOLOR)

Also, when I make the Object plugin object editable, I see the cube, but Use_color is not set to ON.

On 21/08/2014 at 07:17, xxxxxxxx wrote:

Well, possibly this can't be done in Python. In C++ you would fill an ObjectColorProperties structure then assign that to the object with BaseObject::SetColorProperties(). Python doesn't seem to support that structure so maybe it's not possible.

I may be completely wrong, of course, I rarely use Python.

On 21/08/2014 at 08:22, xxxxxxxx wrote:

Ok, thanks for the answer.
In future I will convert it to c++ anyway, so then I can use your advise.

On 22/08/2014 at 12:31, xxxxxxxx wrote:


a way to make it work is not to return your generated object directly but to make it a child object of a null:

    def GetVirtualObjects(self,op,hh) :  
      #parent for all created objects  
      null = c4d.BaseObject(c4d.Onull);  
      # make the cube  
      cube = c4d.BaseObject(c4d.Ocube)        
      cube.SetName("Cube with color")  
      cube[c4d.ID_BASEOBJECT_USECOLOR] = 2                  
      cube[c4d.ID_BASEOBJECT_COLOR] = c4d.Vector(1,0,0)  
      # make the cube a child of the null  
      return null

also OBJECT_USECACHECOLOR has to be set:

plugins.RegisterObjectPlugin(id=1027091, str="My Python Object",g=ExamplePythonObject, description="Opythonobject",info=c4d.OBJECT_GENERATOR|c4d.OBJECT_USECACHECOLOR,icon=bitmaps.BaseBitmap())

best wishes,

On 25/08/2014 at 01:23, xxxxxxxx wrote:

Thanks, it works now.