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

    controlling the dynamics tag

    Scheduled Pinned Locked Moved PYTHON Development
    13 Posts 0 Posters 937 Views
    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.
    • H Offline
      Helper
      last edited by

      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

      On 03/12/2012 at 09:34, xxxxxxxx wrote:

      aw yeah, with your help, I got it!

      c4d.CallButton(simTag, c4d.RIGID_BODY_CACHE_BAKE)

      works a treat, found the ID in dynrigidbodytag.str, which is in the modules folder.

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

        On 03/12/2012 at 09:44, xxxxxxxx wrote:

        alas, the code is less than perfect. the baking works if the tags are selected separately, but if i try to select them all at once only the first one bakes.

        import c4d
        from c4d import gui
        #Welcome to the world of Python

        def main() :
            #gui.MessageDialog('Hello World!')
            
            doc = c4d.documents.GetActiveDocument()
            selected = doc.GetActiveTags()
            
            #print "eeeeeoooaaaa"
            
            for simTag in selected:
                if simTag.GetTypeName() == "Dynamics Body":
                    print simTag.GetName()
                    simTag[c4d.RIGID_BODY_ENABLED]=False
                    
            for simTag in selected:
                if simTag.GetTypeName() == "Dynamics Body":
                    #print simTag.GetTypeName()
                    simTag[c4d.RIGID_BODY_ENABLED]=True
                    c4d.CallButton(simTag, c4d.RIGID_BODY_CACHE_BAKE)
                    simTag[c4d.RIGID_BODY_ENABLED]=False
                    
            for simTag in selected:
                if simTag.GetTypeName() == "Dynamics Body":
                    #print simTag.GetTypeName()
                    simTag[c4d.RIGID_BODY_ENABLED]=True

        if __name__=='__main__':
            
            main()

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

          On 03/12/2012 at 09:58, xxxxxxxx wrote:

          import c4d
            
          def main() :
              selected = doc.GetActiveTags()
            
              for simTag in selected:
                  if simTag.GetTypeName() == "Dynamics Body":
                      c4d.CallButton(simTag, c4d.RIGID_BODY_CACHE_BAKE)
                       
              c4d.EventAdd()       
              
          if __name__=='__main__':
              main()
          

          works for me.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

            On 03/12/2012 at 10:11, xxxxxxxx wrote:

            yes, your code bakes all the tags, though what I want to do is only have one rbd and one collider active at any one time. So the rigid bodies interact with the floor, but not each other.
            The manual way of doing this is to only have one rbd enabled at a time when baking. that doesn't seem to be working for me when scripted.

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

              On 03/12/2012 at 12:41, xxxxxxxx wrote:

              hm,
              that sounds funny. but with your explanation your code snippet does make more sense now.
              will give it a look tomorrow, but for now i cannot come up with a reason for that behaviour.

              edit : you should also try searching the forum on CallButton(). i am 75% sure that there was 
              going on some discussion / problems regarding this method and tags.

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

                THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                On 03/12/2012 at 12:42, xxxxxxxx wrote:

                the problem seems like it can only evaluate one bake per time I run the script. Am I missing some sort of "commit" command for tags?

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                  On 03/12/2012 at 12:43, xxxxxxxx wrote:

                  ok thx!

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

                    THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                    On 03/12/2012 at 13:54, xxxxxxxx wrote:

                    found the other thread i think you were referring to:
                    https://developers.maxon.net/forum/topic/6464/6947_load-edge-selection&KW=CallButton&PID=29059#29059

                    the gist of that thread was that CallButton wasn't safe and Nodedata.Message should be used instead. I've updated my script for that, but no luck. Only the first tag in the selection gets cached.

                    import c4d

                    def main() :

                    doc = c4d.documents.GetActiveDocument()
                        selected = doc.GetActiveTags()
                        
                        for simTag in selected:
                            if simTag.GetTypeName() == "Dynamics Body":
                                simTag[c4d.RIGID_BODY_ENABLED]=False
                                    
                        dc = {}
                        dc['id'] = c4d.DescID(c4d.RIGID_BODY_CACHE_BAKE)    
                        for simTag in selected:
                            if simTag.GetTypeName() == "Dynamics Body":
                                simTag[c4d.RIGID_BODY_ENABLED]=True
                                simTag.Message(c4d.MSG_DESCRIPTION_COMMAND, dc)
                                simTag[c4d.RIGID_BODY_ENABLED]=False

                    for simTag in selected:
                            if simTag.GetTypeName() == "Dynamics Body":
                                simTag[c4d.RIGID_BODY_ENABLED]=True
                                
                        c4d.EventAdd()

                    if __name__=='__main__':
                         main()

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

                      THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                      On 04/12/2012 at 03:29, xxxxxxxx wrote:

                      first of all, as a side note - you do not have to define doc. it is already predefined. there are always
                      some variables predefined as doc (current document) or tp t(he documents particle system).

                      dynamics baking seems to have some problems with multi-selections. the code of yours is perfectly 
                      fine. however, if you fake the step by step selection, it works as expected (at least for me).

                      import c4d
                        
                      def main() :
                          dc = {}
                          dc['id'] = c4d.DescID(c4d.RIGID_BODY_CACHE_BAKE)
                          tagSelection = doc.GetActiveTags()
                        
                          for tag in tagSelection:
                              if tag.GetTypeName() == "Dynamics Body":
                                  tag[c4d.RIGID_BODY_ENABLED]=False
                              else:
                      	    # remove unwanted tags from our selection
                                  tagSelection.remove(tag)
                          
                          for tag in tagSelection :
                      	# set the active tag
                              doc.SetActiveTag(tag)
                              tag[c4d.RIGID_BODY_ENABLED]=True
                              tag.Message(c4d.MSG_DESCRIPTION_COMMAND, dc)
                              tag[c4d.RIGID_BODY_ENABLED]=False
                          
                          for tag in tagSelection:
                               tag[c4d.RIGID_BODY_ENABLED] = True  
                                     
                      if __name__=='__main__':
                           main()
                      
                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

                        THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

                        On 04/12/2012 at 04:53, xxxxxxxx wrote:

                        yup, that works here as well. Tongue

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