Model.hm_proximityinit#
- Model.hm_proximityinit(collection, max_distance, mode=1, check_side=3, proximity_scheme=1, proximity_by_edge=0, min_angle_limit=0, max_angle_limit=180)#
Checks the proximity between elements or components, and stores the results internally. Other APIs can be used to query the results.
This must precede any calls to other hm_proximityget/ hm_proximitymark APIs, and must be followed by a call to
Model.hm_proximityend().- Parameters:
collection (Collection) – The collection containing the entities to query. Valid entities are elements and components.
max_distance (double) – The maximum distance beyond which proximity is not reported.
mode (unsigned int) –
1 - Global proximity (default behavior if not specified)
2 - Proximity between components (entity type of
collectionshould be components only)3 - Self proximity within component (entity type of
collectionshould be components only)check_side (unsigned int) –
1 - Check both sides of the elements
2 - Check the element normal side only
3 - Check ‘outward volume’ side (default behavior if not specified)
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 behavior if not specified).
proximity_by_edge (unsigned int) –
0 - Ignores proximity for nearby edges (default behavior if not specified).
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:
hwReturnStatus- Status object
Example#
Calculate the proximity between all components use a max distance of 2.5 and to query the component pairs#import hm import hm.entities as ent model = hm.Model() components_collection = hm.Collection(model, ent.Component) model.hm_proximityinit(components_collection, max_distance=2.5) _, result = model.hm_proximitygetcomponentpaircount() comp_pair_count = result.numberOfPairs i = 0 while i < comp_pair_count: _, result = model.hm_proximitygetcomponentpair(component_pair_index=i) comp_pair = result.entityPair print(f"Component pair {i}:", [c.id for c in comp_pair]) _, result = model.hm_proximitygetcomponentelementpaircount(component_pair_index=i) elem_pair_count = result.numberOfPair j = 0 while j < elem_pair_count: _, result = model.hm_proximitygetcomponentelementpair( component_pair_index=i, element_pair_index=j ) elem_pair = result.entityPair print(f" Element pair {j}:", [e.id for e in elem_pair]) j += 1 i += 1 model.hm_proximityend()