See hou.DopData for more information about the contents of a DOP simulation. Note that methods of this class implicitly use the simulation data from the current frame.
Methods ¶
__init__()
Creates a new simulation, which is not associated with a node. Use hou.DopNode.simulation to access a DOP network’s simulation.
findData(data_spec)
→ hou.DopData or None
Return the DOP data with the given name. Note that the name may also be a slash-separated path to nested subdata.
If the data path refers to a DOP object, this method returns a hou.DopObject instance. If it refers to a DOP relationship, it returns a hou.DopRelationship instance. Otherwise, it returns a hou.DopData instance.
Note this method implicitly uses the simulation data from the current frame.
See also hou.DopData.findSubData.
findAllData(data_spec)
→ tuple of hou.DopData
Given a pattern, return a tuple of DOP data whose names match the pattern. See also hou.DopSimulation.findData.
objects()
→ tuple of hou.DopData
Return a tuple of all the DOP objects in the simulation.
You cannot index into this list using the object ID (see hou.DopObject.objid). To create a dictionary mapping object IDs to hou.DopObjects, do this:
id_dict = dict((obj.objid(), obj) for obj in simulation.objects())
findObject(obj_spec)
→ hou.DopObject or None
Return the DOP object with the given name, or None
if no object exists
with that name. See also hou.DopSimulation.findData and
hou.DopSimulation.objects.
findAllObjects(obj_spec)
→ tuple of hou.DopObject
Given a pattern, return a tuple of DOP objects whose names match the pattern.
>>> simulation = hou.node("/obj/AutoDopNetwork").simulation() >>> [obj.name() for obj in simulation.findAllObjects("box_object?")] ['box_object1', 'box_object2'] >>> [obj.name() for obj in simulation.findAllObjects("o* b*")] ['obj1', 'obj2', 'box_object1', 'box_object2']
relationships()
→ tuple of hou.DopRelationship
Return a tuple of hou.DopRelationship objects for all the DOP relationships in the simulation.
# The following example assumes you have created two box objects and made # them rigid bodies. >>> simulation = hou.node("/obj/AutoDopNetwork").simulation() >>> relationship = simulation.relationships()[1] >>> affecting_objects = [ ... simulation.objects()[record.field("objid")] ... for record in relationship.records("ObjInAffectors")] >>> [obj.name() for obj in affecting_objects] ['box_object1'] >>> affected_objects = [ ... simulation.objects()[record.field("objid")] ... for record in relationship.records("ObjInGroup")] >>> [obj.name() for obj in affected_objects] ['box_object2']
findRelationship(rel_spec)
→ hou.DopRelationship
Find a DOP relationship by name. Return None if no such relationship with that name exists. See also hou.DopSimulation.relationships.
findAllRelationships(rel_spec)
→ tuple of hou.DopRelationship
Return a tuple of hou.DopRelationship objects whose names match a pattern. See also hou.DopSimulation.relationships and hou.DopSimulation.findRelationship.
dopNetNode()
→ hou.OpNode
Return the DOP network node containing this simulation.
time()
Return the simulation’s current time. This value is often the same
as hou.time(), unless it is called from a Python solver DOP or
the Time Scale
or Offset Time
parameters of the DOP network have been
changed from their default values.
setTime(t, resim_last_timestep=False, force_reset_sim=False, allow_simulation=True)
Sets the simulation’s current time.
resim_last_timestep
Deletes the most recent simulation cache entry before setting the current time.
force_reset_sim
Resets the simulation before moving to the specified time.
allow_simulation
Specifies whether simulation is enabled when moving to the specified time.
Raises hou.PermissionError if the simulation cannot be modified. If the simulation is owned by a DOP network, the simulation time should be changed through the playbar.
timestep()
Returns the length of a simulation timestep.
setTimestep(t)
Sets the length of a simulation timestep.
Raises hou.PermissionError if the simulation cannot be modified. If the simulation is owned by a DOP network, the timestep should be set through the node’s parameters.
memoryUsage()
Return the simulation’s total memory usage.
createObject(name, solve_on_creation_frame)
→ hou.DopObject
Create and return a new DOP object, or return None if the object was not created successfully.
name
The name of the new object.
solve_on_creation_frame
If True, the object will be solved on its first frame of existence.
Raises hou.PermissionError if the simulation cannot be modified (e.g. called from outside a Python DOP).
Use hou.DopData.copyContentsFrom to clone data from an existing object.
removeObject(object)
Remove the given DOP object from the simulation.
object
The hou.DopObject to remove.
Raises hou.PermissionError if the simulation cannot be modified (e.g. called from outside a Python DOP).
createRelationship(name)
→ hou.DopRelationship
Create and return a new DOP relationship, or return None if the relationship was not created successfully.
name
The name of the new relationship.
Raises hou.PermissionError if the simulation cannot be modified (e.g. called from outside a Python DOP).
Use hou.DopData.copyContentsFrom to clone data from an existing relationship, and use hou.DopRelationship.setGroup and hou.DopRelationship.setAffectorGroup to update the “ObjInGroup” and “ObjInAffectors” records.
removeRelationship(rel)
Remove the given DOP relationship from the simulation.
rel
The hou.DopRelationship to remove.
Raises hou.PermissionError if the simulation cannot be modified (e.g. called from outside a Python DOP).