Bug: Constantly updating coordinates



  • 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)
    

  • Global Moderator

    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