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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Bug: Constantly updating coordinates

    Cinema 4D SDK
    python
    2
    2
    499
    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.
    • merkvilsonM
      merkvilson
      last edited by m_adam

      Hello PluginCafe 💙

      I found a weird bug in c4d.OBJECT_GENERATOR plugins.

      Download Plugin

      I tried to make the Matrix generator a child of the 'output' object which is a spline.

      At first glance, everything works correctly, but problems appear as soon as you try to change the coordinates.

      It works correctly if I'm making them a child of a null object or changing hierarchy in different ways but if I need to accomplish this task the way I want, it simply goes crazy 😁

      alt text

      import c4d
      
      class test(c4d.plugins.ObjectData):
      
          def GetVirtualObjects(self, op, hh):
      
              if not op.GetDown(): return None
      
              gch = op.GetAndCheckHierarchyClone(hh, op.GetDown(), c4d.HIERARCHYCLONEFLAGS_ASIS, False) 
              output = gch["clone"]
              gchDirty = gch["dirty"]
      
              if not gchDirty: return output
      
              indexView = c4d.BaseObject(1018545)
              indexView.InsertUnder(output)
              indexView[c4d.ID_MG_MOTIONGENERATOR_MODE]  = 0
              indexView[c4d.MG_OBJECT_LINK]              = output
      
              return output
      
      
      if __name__ == "__main__":
          c4d.plugins.RegisterObjectPlugin(id = 1000004,str = "Test",g = test,description = "",info = c4d.OBJECT_GENERATOR|c4d.OBJECT_INPUT,icon = None)
      
      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi @merkvilson,

        Actually, the issue came from inserting the matrix as a child of the cached spline. The cached spline gets a rotation of X then you apply again the rotation of the generator, which make X+X rotation.

        In order to avoid that, return one null with both object.

        def GetVirtualObjects(self, op, hh):
        
        	if not op.GetDown(): return None
        
        	gch = op.GetAndCheckHierarchyClone(hh, op.GetDown(), c4d.HIERARCHYCLONEFLAGS_ASIS, False) 
        	output = gch["clone"]
        	gchDirty = gch["dirty"]
        
        	if not gchDirty: return output
        
        	null = c4d.BaseObject(c4d.Onull)
        	indexView = c4d.BaseObject(1018545)
        	
        	output.InsertUnder(null)
        	indexView.InsertUnder(null)
        
        	indexView[c4d.ID_MG_MOTIONGENERATOR_MODE]  = 0
        	indexView[c4d.MG_OBJECT_LINK]              = output
        
        	return null
        

        If you have any questions, please let me know.
        Cheers,
        Maxime

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

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