Model.hm_holedetectiongetholedetailsdata#

Model.hm_holedetectiongetholedetailsdata(index, query_key)#

Returns details about a specific query for a hole/tube.

The hole can be general, circular, square and rectangular.

The tude can be general, circular, square and rectangular.

Parameters:
  • index (int) – The index of the hole/tube to get details for, starting from 0.

  • query_key (hwString) –

    The keyword to be used for a specific shape type. Valid values are:

    axis

    The x/y/z coordinates of the axis. Valid for all holes.

    axis_bottom

    The x/y/z coordinates of the bottom axis. Valid for all tubes.

    axis_top

    The x/y/z coordinates of the top axis. Valid for all tubes.

    capped_flag

    Returns true if there is a capped hole. Valid for all tubes.

    center

    The x/y/z coordinates of the center. Valid for all holes.

    center_bottom

    The x/y/z coordinates of the bottom center. Valid for all tubes.

    center_top

    The x/y/z coordinates of the top center. Valid for all tubes.

    depth

    The tube depth. Valid for all tubes.

    entities_list

    The list of ordered nodes or lines. Valid for all holes.

    has_washer

    Returns true if there is a washer. Valid for all 2D mesh holes.

    length

    The side length. Valid for square/rectangular holes.

    length_bottom

    The bottom side length. Valid for square/rectangular tubes.

    length_top

    The top side length. Valid for square/rectangular tubes.

    radius

    The circular radius. Valid for circular holes.

    radius_bottom

    The bottom circular radius. Valid for circular tubes.

    rim_entities_bottom

    The bottom list of ordered nodes or lines. Valid for all tubes.

    rim_entities_top The top list of ordered nodes or lines. Valid for all tubes.

    radius_top The top circular radius. Valid for circular tubes only.

    shape_type

    The shape type. Valid for all holes/tubes.

    tube_barrel_info

    The number of barrels, barrel types, and entity IDs in the format {number_of_barrels {barrel_type {surface/element/face IDs}}}. Valid for all tubes.

    tube_entities_list

    The list of tube surfaces, shells, or solids and face indices. Valid for all tubes.

    width

    The side width. Valid for rectangular holes.

    width_bottom

    The bottom side width. Valid for rectangular tubes.

    width_top

    The top side width. Valid for rectangular tubes.

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