Model.hm_getreplacecomponentpairing#

Model.hm_getreplacecomponentpairing(existing_component_collection, incoming_component_collection, pairing_mode)#

Returns the component pairing for part replacement.

Parameters:
  • existing_component_collection (Collection) – The collection containing the the existing/old component entities.

  • incoming_component_collection (Collection) – The collection containing the the incoming/new component entities.

  • pairing_mode (int) –

    Option to define how pairing should be done:

    0 - Consider bounding box and collision approach.

    1 - Consider matching name of components first and then bounding box and collision approach.

Returns:

Example#

Find the pairing of source components with IDs 301 302 and target components with IDs 503 505#
import hm
import hm.entities as ent

model = hm.Model()

source_collection = hm.Collection(model, ent.Component, [301, 302])
target_collection = hm.Collection(model, ent.Component, [503, 505])

_, resultlist = model.hm_getreplacecomponentpairing(
    existing_component_collection=source_collection,
    incoming_component_collection=target_collection,
    pairing_mode=1,
)

for result in resultlist:
    print("Component 1:", result.component1)
    print("Component 2:", result.component2)