Cannot delete points of point object generator



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

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

    Hello Everyone!

    I'm not able to delete points (in point mode) of a custom point object generator.
    It will result in the following error:

    [

    ](https://www.dailywritingtips.com/forum/misc.php?s=aeda5b5f578c54e23f4eaebbeb9c8d3b&do=bbcode#code)  
    Modeling Kernel Error : Invalid Object  
    Modeling Kernel Error : Failed  
      
    [
    

    ](https://www.dailywritingtips.com/forum/misc.php?s=aeda5b5f578c54e23f4eaebbeb9c8d3b&do=bbcode#code)

    See the code below for a simplified example.
    Point handles will not be drawn in the example code. Move the mouse pointer over the beginning or the end of the line, to select a point when in point mode.

    Best regards
    Tim

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

    [

    ](https://www.dailywritingtips.com/forum/misc.php?s=aeda5b5f578c54e23f4eaebbeb9c8d3b&do=bbcode#code)  
    import math  
    import sys  
    import os  
    import c4d  
    from c4d import bitmaps, gui, plugins, utils  
      
      
    PLUGIN_ID = 9199191  
      
      
    class TestPlugin(plugins.ObjectData) :  
        
      def Init(self, node) :  
          node.ResizeObject(4)  
          node.SetPoint(0, c4d.Vector(  0.0, 0.0,    0.0))  
          node.SetPoint(1, c4d.Vector(100.0, 0.0, -100.0))  
          node.SetPoint(2, c4d.Vector(200.0, 0.0,  100.0))  
          node.SetPoint(3, c4d.Vector(300.0, 0.0, -100.0))  
          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)  
      
          splineObj = c4d.SplineObject(op.GetPointCount(), c4d.SPLINETYPE_LINEAR)  
          splineObj.SetAllPoints(op.GetAllPoints())  
      
          return splineObj  
        
      
    if __name__ == "__main__":  
      path, file = os.path.split(__file__)  
      bmp = bitmaps.BaseBitmap()  
      bmp.InitWith(os.path.join(path, "res", "some.tif"))  
      plugins.RegisterObjectPlugin(  
          id = PLUGIN_ID,  
          str = "Py-TestPlugin",  
          g = TestPlugin,  
          description = "Opytestplugin",  
          icon = bmp,  
          info = c4d.OBJECT_GENERATOR | c4d.OBJECT_POINTOBJECT )  
      
    [
    

    ](https://www.dailywritingtips.com/forum/misc.php?s=aeda5b5f578c54e23f4eaebbeb9c8d3b&do=bbcode#code)



  • On 14/02/2018 at 04:39, xxxxxxxx wrote:

    Hi,

    it looks like you wan to generate a spline. Similar to your other thread (Polygons disappear with Polygon Object Generator), you don't need to set the OBJECT_POINTOBJECT flag on registration.
    Instead you need to set the OBJECT_ISSPLINE flag on registration. And then you don't override GetVirtualObjects() but instead GetContour(). I suggest to take a look at the Py-DoubleCircle example.



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

    Hello Andreas,

    I don't want to generate a spline object. The code above is a simplified example for the problem and I generate the spline only for visualization. The actual plugin I'm working on is a more complex point object generator and when I delete points in point mode I get the error mentioned above.

    Best regards
    Tim



  • On 21/02/2018 at 09:18, xxxxxxxx wrote:

    Hi Tim,

    sorry, for the long time to answer here.

    I can reproduce the error message, but unfortunately have to say, it is an undefined use-case. By the way, you can produce the same error by trying to delete points from our FFD deformer.

    This is the result of some internal changes in the recent past. An issue got created in our bug tracker. But please be aware, this is no functional issue (at least not as far as I can see), but only an erroneously thrown error message in the Console.

    Now, for your actual issue (deleting points) : I'm afraid, it's simply not the way a generator is designed in C4D. At least I am not aware of any generator, allowing the deletion of (control-)points. I think something like this is usually achieved with a generator (generating your complex point object) with an input point (or rather polygon) object.



  • On 26/02/2018 at 03:11, xxxxxxxx wrote:

    Thanks for your help Andreas!

    I solved the problem with a workaround / hack by listening to delete key press events and then deleting the points in my own function.

    Best regards
    Tim


Log in to reply