Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Object plugin and object color

    Scheduled Pinned Locked Moved PYTHON Development
    7 Posts 0 Posters 622 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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
      
      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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.

        Steve

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

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

                Hello,

                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  
                      cube.InsertUnder(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,
                Sebastian

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

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

                  Thanks, it works now.
                  Pim

                  1 Reply Last reply Reply Quote 0
                  • First post
                    Last post