Model.hm_holedetectioninit#

Model.hm_holedetectioninit()#

Initializes the hole/tube detection module. This must precede any calls to other hm_holedetection APIs, and must be followed by a call to Model.hm_holedetectionend().

“Major” database changes made while inside of the hole detection module will invalidate and delete any results.

Returns:

Example#

Detect holes of any shape in all surfaces in the model and write the hole details shape_type, center, radius, and entities_list to a text file.#
import hm
import hm.entities as ent

model = hm.Model()

with open("C:/temp/holes.txt", "w") as holesfile:

    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

    _, result = model.hm_holedetectiongetnumberofholes()
    num_holes = result.numberOfHoles

    if num_holes > 0:

        holesfile.write(f"Number of holes = {num_holes}\n\n")

        for n in range(num_holes):

            holesfile.write(f"Queried data details of hole {n+1}\n")

            _, result = model.hm_holedetectiongetholedetailsdata(
                index=n, query_key="shape_type"
            )
            holesfile.write(f"shape-type = {result.queryValue}\n")

            _, result = model.hm_holedetectiongetholedetailsdata(
                index=n, query_key="center"
            )
            holesfile.write(f"center = {result.queryValue}\n")

            _, result = model.hm_holedetectiongetholedetailsdata(
                index=n, query_key="radius"
            )
            holesfile.write(f"radius = {result.queryValue}\n")

            _, result = model.hm_holedetectiongetholedetailsdata(
                index=n, query_key="entities_list"
            )
            holesfile.write(f"entities_list = {result.queryValue}\n\n")

    else:

        holesfile.write("Holes not detected.\n")

    model.hm_holedetectionend()

    holesfile.close()