Model.hm_collisiongetcomponentpair#

Model.hm_collisiongetcomponentpair(collisionType, componentIndex, includeIgnored=False)#

Returns the list of components of a collision pair. This must be preceded by a call to relevant hm_collision functions to generate the collision data. In addition, the pair_results argument to Model.hm_collisioncheck() must be set to True.

For each collision type there is a list of pairs of colliding components. For each colliding component pair, there is a list of colliding entity pairs. Thus, their is a hierarchy of data with the tree looking like this:

collision type \(\rightarrow\) component pairs \(\rightarrow\) entity pairs

The data is therefore accessed as:

  1. Get the number of colliding component pairs.

  2. Get the component IDs for each component pair.

  3. Get the number of intersected entities for each component pair.

  4. Get the entity types, IDs, and faces (for intersections) or the entity types, IDs, faces, depths and directions (for penetrations) for each intersected entity pair.

Parameters:
  • collisionType (int) –

    The type of collision to query:

    0 - intersections

    1 - penetrations

  • componentIndex (int) – The index of the component pair to query, starting from 0. The total number of component pairs for a specific collision_type can be found using Model.hm_collisiongetcomponentpaircount().

  • includeIgnored (bool) –

    Specifies if results ignored when the allowable_depth value which is specified via Model.hm_collisioninit() should be reported or not:

    False - Do not include ignored results (default).

    True - Include ignored results.

Returns:

Examples#

Find intersect surfaces from IDs 1 - 10 , and to get the detailed list of entities for each intersection#
import hm
import hm.entities as ent

model = hm.Model()

model.hm_collisioninit()

checking_surfs = hm.Collection(model,ent.Surface,list(range(1,11)))
model.hm_collisioninit()
model.hm_collisionentitycreate(collection=checking_surfs,dimension=0,thickness_type=1,
                                thickness=0,edge_penetration=0,midside_nodes=0,split_quads=0,
                                used_topology=0,grouping_identifier=False,offset=0
                                )
model.hm_collisioncheck(penetrated_surfaces=checking_surfs,pair_results=True)

_, result = model.hm_collisiongetcomponentpaircount(collisionType=0)

component_pair_count = result.numberOfCollisionPairs

if component_pair_count > 0:
    for i in range(0,component_pair_count):

        _, result = model.hm_collisiongetcomponentpair(collision_type=0,componentIndex=i)
        component_pairs = result.componentPair

        _, result = model.hm_collisiongetcomponententitypaircount(collision_type=0,component_index=i)
        entity_pair_count = result.numberOfEntityPairs

        if entity_pair_count !=0:
            for j in range(0,entity_pair_count):

                _, result = model.hm_collisiongetcomponententitypair(collision_type=0,component_index=i,entity_index=j)
                print("Collision entity1 [type, id, faceIndex]: ", [result.entityType1, result.entityID1, result.faceIndex1])
                print("Collision entity2 [type, id, faceIndex]: ", [result.entityType2, result.entityID2, result.faceIndex2])

model.hm_collisionend()
Find intersect surfaces from IDs 1 - 10 , use the thickness assigned to the surface components , and to get the detailed list of entities for each intersection#
import hm
import hm.entities as ent

model = hm.Model()

model.hm_collisioninit()

checking_surfs = hm.Collection(model,ent.Surface,list(range(1,11)))
model.hm_collisioninit()
model.hm_collisionentitycreate(collection=checking_surfs,dimension=0,thickness_type=1,
                                thickness=0,edge_penetration=0,midside_nodes=0,split_quads=0,
                                used_topology=0,grouping_identifier=False,offset=0
                                )
model.hm_collisioncheck(penetrated_surfaces=checking_surfs,pair_results=True)

_, result = model.hm_collisiongetcomponentpaircount(collisionType=1)

component_pair_count = result.numberOfCollisionPairs

if component_pair_count > 0:
    for i in range(0,component_pair_count):

        _, result = model.hm_collisiongetcomponentpair(collision_type=0,componentIndex=i)
        component_pairs = result.componentPair

        _, result = model.hm_collisiongetcomponententitypaircount(collision_type=1,component_index=i)
        entity_pair_count = result.numberOfEntityPairs

        if entity_pair_count !=0:
            for j in range(0,entity_pair_count):

                _, result = model.hm_collisiongetcomponententitypair(collision_type=1,component_index=i,entity_index=j)
                print("Collision entity1 [type, id, faceIndex]: ", [result.entityType1, result.entityID1, result.faceIndex1])
                print("Collision entity2 [type, id, faceIndex]: ", [result.entityType2, result.entityID2, result.faceIndex2])
                print("Collision depth: ", result.depth)
                print("Collision direction: ", [result.directionX, result.directionY, result.directionZ])

model.hm_collisionend()