Polygons disappear with Polygon Object Generator

  • On 13/02/2018 at 11:00, xxxxxxxx wrote:

    (Object Generator Plugin in Python for Cinema 4D R19.024 on macOS Sierra)

    Hello Everyone!

    If I register an object plugin as a c4d.OBJECT_GENERATOR | c4d.OBJECT_POLYGONOBJECT and return a polygon object from the GetVirtualObjects() method, the polygon object will disappear from the view, when I switch from model mode to point mode.

    If the plugin will be registered as a c4d.OBJECT_GENERATOR | c4d.OBJECT_POINTOBJECT, the polygon object will NOT disappear from the view, when I switch from model mode to point mode.

    Like with the point object generator, I would like to be able to see the polygon object of a polygon object generator when I switch to point mode. Is this possible?

    See the code below for a simplified example.

    Best regards

    PS: I'm new to Cinema 4D plugin development and new to Cinema 4D in general.

    import math  
    import sys  
    import os  
    import c4d  
    from c4d import bitmaps, gui, plugins, utils  
    PLUGIN_ID = 9119119  
    class TestPlugin(plugins.ObjectData) :  
      def Init(self, node) :  
          return True  
      def GetVirtualObjects(self, op, hierarchyhelp) :  
          dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)  
          if dirty is False: return op.GetCache(hierarchyhelp)  
          return self.CreateSimplePolyObj()  
      def CreateSimplePolyObj(self) :  
          op = c4d.PolygonObject(4, 1)  
          op.SetPoint(0, c4d.Vector(  0.0, 0.0,   0.0))  
          op.SetPoint(1, c4d.Vector(100.0, 0.0,   0.0))  
          op.SetPoint(2, c4d.Vector(100.0, 0.0, 100.0))  
          op.SetPoint(3, c4d.Vector(  0.0, 0.0, 100.0))  
          polygon = c4d.CPolygon(0, 1, 2, 3)  
          op.SetPolygon(0, polygon)  
          op.SetPhong(True, 1, utils.Rad(80.0))  
          return op  
    if __name__ == "__main__":  
      path, file = os.path.split(__file__)  
      bmp = bitmaps.BaseBitmap()  
      bmp.InitWith(os.path.join(path, "res", "some.tif"))  
          id = PLUGIN_ID,  
          str = "Py-TestPlugin",  
          g = TestPlugin,  
          description = "Opytestplugin",  
          icon = bmp,  
          info = c4d.OBJECT_GENERATOR | c4d.OBJECT_POLYGONOBJECT )  

  • On 14/02/2018 at 03:05, xxxxxxxx wrote:


    welcome to the Plugin Café forums 🙂

    There seems to be common misconception of our SDK docs (a sign we need to improve them). Just recently we had another thread by merkvilson with the same issue: "Hide child of Object plugin" (a bit down the line).
    To make it short, don't use OBJECT_POLYGONOBJECT when registering your generator. It's just a generator (even if generating a polygon object). OBJECT_POLYGONOBJECT is used in special cases only. The objectdata_latticeplanemodifier example (sorry, just realized I'm linking to a C++ example in Python forum) uses OBJECT_POINTOBJECT to achieve the behavior of the controlling plane. OBJECT_POLYGONOBJECT would be used similarly.

  • On 14/02/2018 at 05:29, xxxxxxxx wrote:

    Hi Andreas,

    the code above is only a simplified example of the problem.

    I'm working on a more complex point generator plugin. The generated object has some (control) points which should be editable in point mode. The final object, which will be displayed in model mode, is a complex polygon object, which is based on the (control) points of the point object. Everything worked as expected until I tried to delete points of the point object in point mode. I created another post about that problem. A solution was to switch the plugin registration from a point object to a polygon object. Now I'm able to delete the (control) points, but the polygon object, which I generate in GetVirtualObjects(), will not be displayed anymore when I switch from model mode to point mode!

    Best regards

Log in to reply