Model.hm_proximityend#

Model.hm_proximityend()#

Clears the proximity calculation data and memory.

This must be preceded by a call to Model.hm_proximityinit().

Returns:

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()