Jump to content

break dop constraints in python dop solver


catchyid

Recommended Posts

Hi, 

I am using Script solver inside a DOP RBD bullet sim, I was able to change velocities of individual RBD packed objects, however I don't know how to access/modify constraints network parameters (e.g strength, add/remove broken group, etc.)? The constraint network in defined globally "Relationships" subdata (i.e. not attached to each object), below is the code I am trying to write :

from __future__ import with_statement

def solveForObjects( solver_data, new_dop_objects, existing_dop_objects, time, timestep):

    dopsim = solver_data.simulation()
    relationships   = dopsim.findRelationship("constraintnetwork1")
    constraintsnetwork = relationships.findSubData("constraintnetwork") # geometry lives inside 'constraintnetwork' subdata
    geo = constraintsnetwork.findSubData("Geometry") #that works, but it's not a hou.Geometry that can be edited!
    with    constraintsnetwork.editableGeometry() as geo: #error: AttributeError: 'DopData' object has no attribute 'editableGeometry
        #.... do something here

image.thumb.png.d7008f442258175d1f1854fe626f1259.png

image.thumb.png.764cef8109e8270498a689a6987a40d1.png

 

Link to comment
Share on other sites

  • 9 months later...
On 2020/11/29 at 11:34 AM, catchyid said:

Hi, 

I am using Script solver inside a DOP RBD bullet sim, I was able to change velocities of individual RBD packed objects, however I don't know how to access/modify constraints network parameters (e.g strength, add/remove broken group, etc.)? The constraint network in defined globally "Relationships" subdata (i.e. not attached to each object), below is the code I am trying to write :

from __future__ import with_statement

def solveForObjects( solver_data, new_dop_objects, existing_dop_objects, time, timestep):

    dopsim = solver_data.simulation()
    relationships   = dopsim.findRelationship("constraintnetwork1")
    constraintsnetwork = relationships.findSubData("constraintnetwork") # geometry lives inside 'constraintnetwork' subdata
    geo = constraintsnetwork.findSubData("Geometry") #that works, but it's not a hou.Geometry that can be edited!
    with    constraintsnetwork.editableGeometry() as geo: #error: AttributeError: 'DopData' object has no attribute 'editableGeometry
        #.... do something here

image.thumb.png.d7008f442258175d1f1854fe626f1259.png

image.thumb.png.764cef8109e8270498a689a6987a40d1.png

 

u should just modify some code,like this:

from __future__ import with_statement

def solveForObjects(solver_data, new_dop_objects, existing_dop_objects, time, timestep):
    frame=time/timestep
    sim=solver_data.simulation()
    cnst_rel=sim.findRelationship('constraintnetwork1')
    
    for dop_object in existing_dop_objects:
        with cnst_rel.editableGeometry('constraintnetwork/Geometry') as geo_cnst:
            for prim in geo_cnst.prims():
                if(prim.attribValue('angle')>.2):
                    prim.setAttribValue('constraint_name','Glue')

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...