Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

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

    Cinema 4D SDK
    python r21 s22
    2
    3
    531
    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.
    • oli_dO
      oli_d
      last edited by Manuel

      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)

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        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.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 0
        • oli_dO
          oli_d
          last edited by

          Merci Maxime !

          It's work perfectly !

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