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

    Object Generator Plugin With Dynamic Objects

    Cinema 4D SDK
    python
    2
    3
    710
    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 merkvilson

      Hello Plugincafe 🙂

      I have a simple task but unfortunately, I can't find the solution in docs.

      I have an object generator plugin which generates a cube object with a rigid body tag onto it.
      When I'm playing the animation, no dynamics takes place.

      class testPlugin(c4d.plugins.ObjectData):
      
          def GetVirtualObjects(self, op, hh):
      
              cube = c4d.BaseObject(c4d.Ocube) #Cube
              tag = cube.MakeTag(180000102) #Rigid body tag
              
              #This Crashes C4D.
              #op.GetDocument().ExecutePasses(c4d.threading.GeGetCurrentThread(), True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
      
              return cube
      

      I also tried to create a virtual document and then return the clone but the result is the same. no animation takes place.

      I guess I'm using ExecutePasses() in a wrong way.

      Would like to get more info about this.

      1 Reply Last reply Reply Quote 0
      • merkvilsonM
        merkvilson
        last edited by

        it is worth mentioning that it would be better if this code will return an error message instead of crashing c4d. 😁

        op.GetDocument().ExecutePasses(c4d.threading.GeGetCurrentThread(), True, True, True, c4d.BUILDFLAGS_INTERNALRENDERER)
        
        1 Reply Last reply Reply Quote 0
        • S
          s_bach
          last edited by

          Hello,

          GetVirtualObjects() is called when the scene is updated. ExecutePasses() updates the scene. So you want to update the scene while the scene is updated. That's bad.

          Also, you create a virtual cube and add a tag to that cube. But you do not add the cube to any document. So updating any document would have no effect on that cube.

          Typically, one does not add a simulation tag to a virtual object. Such a tag is typically added to the generator that create the virtual objects e.g. you add a simulation tag to a MoGraph cloner to animate it virtual child objects.

          best wishes,
          Sebastian

          MAXON SDK Specialist

          Development Blog, MAXON Registered Developer

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