Model.hm_holedetectionfindmates#

Model.hm_holedetectionfindmates(max_angle=1.0, max_distance=10.000000, max_lateral_distance=1.000000, max_lateral_factor=DBL_MAX, allow_hole_to_tube=0, allow_mismatched_shapes=0, allow_self=0)#

Runs the hole detection mating functions for finding holes and tubes mating ‘groups’. This must be preceded by a call to Model.hm_holedetectionfindholes().

Parameters:
  • max_angle (double) – The maximum angle between the center line of holes/tubes. Default value 1.0.

  • max_distance (double) – The maximum normal distance between the center of holes/tubes. Default value 10.0.

  • max_lateral_distance (double) – The maximum lateral distance to allow. Default value 1.0.

  • max_lateral_factor (double) – The maximum lateral distance to allow, defined by scaling the diameter of the current hole using this factor. This is not used by default and must be explicitly defined. This is ignored if max_lateral_distance is also defined.

  • allow_hole_to_tube (int) –

    0 - Do not allow mates to be found between holes and tubes (default)

    1 - Allow mates to be found between holes and tubes

  • allow_mismatched_shapes (int) –

    0 - Do not allow mates to be found between different shapes (default)

    1 - Allow mates to be found between different shapes

  • allow_self (int) –

    0 - Do not allow mates to be found within the same component (default)

    1 - Allow mates to be found within the same component

Returns:

Example#

Detect mating holes of any shape in all surfaces in the model and write the mate details to a text file.#
import hm
import hm.entities as ent

model = hm.Model()

with open("C:/temp/mates.txt", "w") as matesfile:

    surf_collection = hm.Collection(model, ent.Surface)

    model.hm_holedetectioninit()
    model.hm_holedetectionsetentities(collection=surf_collection)
    model.hm_holedetectionsetholeparams(hole_shape=31)
    model.hm_holedetectionfindholes(find=1)  # For holes we need to set find=1
    model.hm_holedetectionfindmates()

    _, result = model.hm_holedetectiongetnumberofmates()

    num_mates = result.numberofMates

    if num_mates > 0:
        matesfile.write(f"Number of mates = {num_mates}\n")

        for n in range(num_mates):
            _, result = model.hm_holedetectiongetmatedetails(index=n)
            matesfile.write(f"Queried data details of mate {n+1}\n")
            matesfile.write(f"totalLength = {result.totalLength}\n")
            matesfile.write(f"centerTopCoordinates = {result.centerTopCoordinates}\n")
            matesfile.write(f"centerBottomCoordinates = {result.centerBottomCoordinates}\n")
            matesfile.write(f"centerCoordinates = {result.centerCoordinates}\n")
            matesfile.write(f"numberOfIndeces = {result.numberOfIndeces}\n")
            matesfile.write(f"listOfIndeces = {result.listOfIndeces}\n")

    else:
        matesfile.write("Mates not detected.\n")

    model.hm_holedetectionend()

    matesfile.close()