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

    PYTHON GENERATOR ISSUES

    Cinema 4D SDK
    r20 python
    2
    3
    406
    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.
    • gheyretG
      gheyret
      last edited by

      I want to use python generator to return cloner object. and clone object "A" on the object "B" surface, but it's return odd result, I don't know what step is wrong.

      And this is my python code here:

      import c4d
      #Welcome to the world of Python
      
      def main():
          cloner = c4d.BaseObject(1018544)
          sphere = c4d.BaseObject(c4d.Osphere).GetClone(0)
          
          plane = c4d.BaseObject(c4d.Oplane).GetClone(0)
          
          bc = c4d.BaseContainer()
          bc.SetLong(c4d.ID_MG_MOTIONGENERATOR_MODE,0)
          bc.SetLink(c4d.MG_OBJECT_LINK,plane)
          
          cloner.SetData(bc)
          sphere.InsertUnder(cloner)
          
          return cloner
      
      

      www.boghma.com

      1 Reply Last reply Reply Quote 0
      • CairynC
        Cairyn
        last edited by

        I don't know what "odd result" means, but just from looking at the code: the plane is local to main() and you don't insert it anywhere in your cloner hierarchy, so the link that points to it becomes invalid when you leave the function.

        Also, you overwrite your cloner's complete base container? Not sure whether that works this way. Try setting only the relevant data.

        Also, cloning brand new objects seems unnecessary to me.

        import c4d
        #Welcome to the world of Python
        
        def main():
            cloner = c4d.BaseObject(1018544)
            sphere = c4d.BaseObject(c4d.Osphere)
            null = c4d.BaseObject(c4d.Onull)
            plane = c4d.BaseObject(c4d.Oplane)
            
            cloner[c4d.ID_MG_MOTIONGENERATOR_MODE] = 0
            cloner[c4d.MG_OBJECT_LINK] = plane
            
            cloner.InsertUnder(null)
            plane.InsertUnder(null)
            sphere.InsertUnder(cloner)
        
            return null
        

        Also, the default count for the cloner is 20, so there will only be 20 spheres appear on the plane.
        Also, the spheres are very big in comparison with the plane.

        gheyretG 1 Reply Last reply Reply Quote 0
        • gheyretG
          gheyret @Cairyn
          last edited by

          @Cairyn
          Thank you for your reply.
          The "odd result" it's means the scene is empty , no objects were generated.
          According to your explanation, I have solved the problem.
          And it's just an exercise code.
          Thank you again !

          www.boghma.com

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