controlling the dynamics tag



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

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

    Is there any way to trigger a bake in the dynamics tag through scripting?
    I've got a lot of objects i want to bake independently and it's a drag to do manually.



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

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

    there is c4d.CallButton(op,id), but if i remember correctly you might run into some problems with this method and tags. at least i think there has been a thread on this topic here some time ago.

    http://www.thirdpartyplugins.com/python/modules/c4d/index.html#c4d.CallButton



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

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

    thanks! Any idea how to find out the button ID? that entry in the python documentation was sparse to say the least!



  • 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.



  • 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()



  • 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.



  • 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.



  • 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.



  • 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?



  • 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!



  • 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://plugincafe.maxon.net/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()



  • 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()
    


  • 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. 


Log in to reply