Effector created with python doesn't work anymore after closing the file



  • Hi,
    When I run the following code that creates an effector, everything works perfectly. If I save the file, close it and open it again, the effector does nothing and it is impossible to make it work.

    import c4d
    
    
    def main():
        res = c4d.BaseObject(c4d.Onull)
        cloner = c4d.BaseObject(1018544)
        cloner.InsertUnder(res)
    
        rdm_effector = c4d.BaseObject(1018643)   
        rdm_effector.InsertUnder(res)
        
        inex_data = cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST]
        inex_data.InsertObject(rdm_effector,1)
        cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] = inex_data
    
        if op:
            op.InsertUnder(cloner)
    
        doc.InsertObject(res)
        c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    

    With CallCommand it works, but it's not very practical.

    import c4d
    from c4d import gui
    
    def main():
    
        res = c4d.BaseObject(c4d.Onull)
        cloner = c4d.BaseObject(1018544)
        cloner.InsertUnder(res)
    
        if op:
            op.InsertUnder(cloner)
    
        doc.InsertObject(res)
    
        doc.SetActiveObject(cloner)
    
        c4d.CallCommand(1018643) # Effecteur Randomisation
        c4d.EventAdd()
        return
    
    if __name__=='__main__':
        main()
    

    Bug or incompetence?

    (C4D r21.207 and s22.016 on macos 10.13.6)



  • Hi @oli_d you should call rdm_effector.Message(c4d.MSG_MENUPREPARE, doc) after its insertion in the doc like

    import c4d
    
    
    def main():
        res = c4d.BaseObject(c4d.Onull)
        cloner = c4d.BaseObject(1018544)
        cloner.InsertUnder(res)
    
        rdm_effector = c4d.BaseObject(1018643)   
        rdm_effector.InsertUnder(res)
        
        inex_data = cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST]
        inex_data.InsertObject(rdm_effector,1)
        cloner[c4d.ID_MG_MOTIONGENERATOR_EFFECTORLIST] = inex_data
    
        if op:
            op.InsertUnder(cloner)
    
        doc.InsertObject(res)
        rdm_effector.Message(c4d.MSG_MENUPREPARE, doc)
        c4d.EventAdd()
    
    if __name__=='__main__':
        main()
    

    Cheers,
    Maxime.



  • Merci Maxime !

    It's work perfectly !


Log in to reply