Model.hm_checkproximity#

Model.hm_checkproximity(collection, max_proximity, mode=1, check_side=3, proximity_scheme=1, proximity_by_edge=0, min_angle_limit=0, max_angle_limit=0)#

Checks proximity between input entities and returns list of entities within the specified proximity. The output depends on the mode argument as defined below.

Parameters:
  • collection (Collection) – The collection containing the entities.

  • max_proximity (double) – The maximum distance beyond which an entity is not considered.

  • mode (unsigned int) –

    1 - Global proximity (default)

    2 - Proximity between components (collection must contain components)

    3 - Self proximity within components (collection must contain components)

  • check_side (unsigned int) –

    1 - Check both sides of elements

    2 - Check only the element normal side

    3 - Check ‘outward volume’ side (default)

    4 - Check ‘inward volume’ side

  • proximity_scheme (unsigned int) –

    0 - Checks basic proximity along a ray from the element center along the normal direction.

    1 - Checks comprehensive proximity. Reports any proximity within an imaginary offsetted volume of the element (default).

  • proximity_by_edge (unsigned int) –

    0 - Ignores proximity for nearby edges (default)

    1 - Considers proximity for nearby edges.

  • min_angle_limit (double) – If the angle between the proximate element pairs is less than this value, such pairs are not reported.

  • max_angle_limit (double) – If the angle between the proximate element pairs is greater than this value, such pairs are not reported.

Returns:

For mode=1:

  • HmQueryResult - Result object containing the output values:

    • elements1 (EntityList) - The list of elements for which a proximity is found.

    • elements2 (EntityList) - The list of paired elements for the elements in elements1.

For mode=2 and mode=3:

  • HmQueryResult - Result object containing the output values:

    • data_by_component (HmQueryResultList) - Result list object containing HmQueryResult objects with the following output data:

      • component (Entity) - The component for which the proximity is checked.

      • elements1 (EntityList) - The list of elements for which a proximity is found.

      • elements2 (EntityList) - The list of paired elements for the elements in elements1.

Example#

Find proximity between all components using a max distance of 2.5#
import hm
import hm.entities as ent

model = hm.Model()

components = hm.Collection(model, ent.Component)

_, result = model.hm_checkproximity(
    collection=components,
    max_proximity=2.5,
    mode=1,
    min_angle_limit=10,
    max_angle_limit=80
)

print("Number of identified elements with proximity:", len(result.elements1))
print("Number of paired elements:", len(result.elements2))
Find proximity per component (mode=2) using a max distance of 2.5#
import hm
import hm.entities as ent

model = hm.Model()

components = hm.Collection(model, ent.Component)

_, result = model.hm_checkproximity(
    collection=components,
    max_proximity=2.5,
    mode=2,
    min_angle_limit=10,
    max_angle_limit=80
)

for comp_result in result.data_by_component:
    print(f"Component ID: {comp_result.component.id}")
    print("Number of identified elements with proximity:", len(comp_result.elements1))
    print("Number of paired elements:", len(comp_result.elements2))