Model.hm_collisiongetcomponentlinesegmentcount#

Model.hm_collisiongetcomponentlinesegmentcount(comp_index, include_ignored=False)#

Returns the line segment coordinates for a component collision pair. Once the call to the relevant hm_collision functions to generate the collision data is made, this function can follow. In addition, the pair_results argument to Model.hm_collisioncheck() must be set to 1.

For each intersecting type of collision, there is a list of pairs of intersecting components. For each intersecting component pair, there is a list of intersection line segments.

To execute this function, the below sequence of data collection is required:

  1. Get the number of colliding component pairs.

  2. Get the number of intersection line segments for each component pair.

  3. Get the line segments for each intersected component pair.

Parameters:
  • comp_index (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().

  • include_ignored (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:

Example#

Create nodes at the center of intersection line segments for intersect components with ID 1 and 2#
import hm
import hm.entities as ent

model = hm.Model()

model.hm_collisioninit(tolerance=10**(-5))

comp_collection_1 = hm.Collection(model,ent.Element,hm.Collection(model,ent.Component,[1]))
comp_collection_2 = hm.Collection(model,ent.Element,hm.Collection(model,ent.Component,[2]))

model.hm_collisionentitycreate(collection=comp_collection_1,dimension=0,thickness_type=0,
                                thickness=0,edge_penetration=0,midside_nodes=0,split_quads=0,
                                used_topology=0,grouping_identifier=False,offset=0
                                )
model.hm_collisionentitycreate(collection=comp_collection_2,dimension=0,thickness_type=0,
                                thickness=0,edge_penetration=0,midside_nodes=0,split_quads=0,
                                used_topology=0,grouping_identifier=False,offset=0
                                )
int_elems = hm.Collection(model,ent.Element,populate=False)
model.hm_collisioncheck(intersected_elements=int_elems,store_segments=True,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_collisiongetcomponentlinesegmentcount(comp_index=i)
        linesegmentcount = result.numberOfLineSegments

        if linesegmentcount!=0:
            for j in range(0,linesegmentcount):
                _, result = model.hm_collisiongetcomponentlinesegment(component_index=i,linesegment_index=j)
                linesegments_start = result.lineSegment1
                linesegments_end = result.lineSegment2

                curr_x = (linesegments_start[0] + linesegments_end[0])/2
                curr_y = (linesegments_start[1] + linesegments_end[1])/2
                curr_z = (linesegments_start[2] + linesegments_end[2])/2

                # Creating node with global coordinates calulated from above
                ent.Node(model,globalx=curr_x, globaly=curr_y, globalz=curr_z)
model.hm_collisionend()