Model.hm_holedetectionsettubeparams#
- Model.hm_holedetectionsettubeparams(tube_shape, tube_type, feature_angle=0, max_geom_dev_percent=-1, max_height=0, max_offset_angle=0, max_offset_plane_dev=0, max_planar_dim=0, max_smooth_edge_angle=-1, merge_connected_barrels=1, min_cone_angle=0, min_planar_dim=0, min_height=0)#
Defines parameters for finding tubes in both geometry and FE. Multiple calls to this function can be made to override or redefine the parameters for each hole shape. Settings are cleared on any call to
Model.hm_holedetectioninit()/Model.hm_holedetectionend(). This must be preceded by a call toModel.hm_holedetectioninit(). Onlytube_shapeandtube_typeare mandatory. All other parameters are optional and have default values. Parameters can be specified in any order.- Parameters:
tube_shape (int) –
The shape of tube the parameters are being defined for.
Bit values are used and the value is calculated as (Bit0 + 2*Bit1 + 4*Bit2 + 8*Bit3 + 16*Bit4). Valid Bit options are:
Bit0
Consider general tubes. Valid values are:
0 - Do not consider general tubes
1 - Consider general tubes
Bit1
Consider circular tubes. Valid values are:
0 - Do not consider circular tubes
1 - Consider circular tubes
Circular tubes: The distance from any of its nodes to the calculated center must not differ from the calculated radius by more than
max_geom_dev_percent. Also, no edge must make an angle greater thanmax_smooth_edge_anglewith either adjoining edge.Bit2
Consider rounded tubes. Valid values are:
0 - Do not consider rounded tubes
1 - Consider rounded tubes
Rounded tubes: The distance from any of its nodes on the rounded ends to the respective calculated centers must not differ from the calculated radii by more than
max_geom_dev_percent. The radii must be withinmax_geom_dev_percentof each other. Also, no edge must make an angle greater thanmax_smooth_edge_anglewith either adjoining edge. Opposite straight sides must have lengths withinmax_geom_dev_percentof each other.Bit3
Consider square tubes. Valid values are:
0 - Do not consider square tubes
1 - Consider square tubes
Square tubes: At every node except four, no edge must make an angle greater than
max_smooth_edge_angle. At those four nodes, the measured angle is withinmax_geom_dev_percentof 90 degrees. And, all four sides must have lengths withinmax_geom_dev_percentof their average.Bit4
Consider rectangular tubes. Valid values are:
0 - Do not consider rectangular tubes
1 - Consider rectangular tubes
Rectangular tubes: At every node except four, no edge must make an angle greater than
max_smooth_edge_angle. At those four nodes, the measured angle is withinmax_geom_dev_percentof 90 degrees. Opposite pairs of sides must have lengths withinmax_geom_dev_percentof each other.Show Bit value calculator
Radio Button Table Option Name Value Consider general tubes (Bit0) Consider circular tubes (Bit1) Consider rounded tubes (Bit2) Consider square tubes (Bit3) Consider rectangular tubes (Bit4) Calculated argument value: 0 tube_type (int) –
0 - General
1 - Open
2 - Capped on one side
feature_angle (double) – Used to identify each connected sequence of feature edges. Specifically a feature edge is one whose adjoining faces form an angle greater than this value. Acceptable values are [0.0, 180], otherwise closer extreme is used. Default value -30.0.
max_geom_dev_percent (double) – See
tube_shape. Acceptable values are [0.0, 100.0], otherwise closer extreme is used. If less than 0.0, this check is skipped. Default value -1.max_height (double) – The distance between the center of the rims cannot exceed this value. If less than or equal to 0.0, this check is skipped. Default value 0.0.
max_offset_angle (double) – For FE tubes, neither normal associated with each rim differs by more than this angle from primary axis. If less than or equal to 0.0, check is avoided - a value of 45.0 is suggested. Default value 0.0.
max_offset_plane_dev (double) – Applied to each rim. No node on the perimeter of a tube must exceed this distance from the mean plane. If less than or equal to 0.0, this check is skipped. Default value 0.0.
max_planar_dim (double) – Applied to each rim. The maximum planar dimension of tube hole cannot exceed this value. If less than or equal to 0.0, this check is skipped. Default value 0.0.
max_smooth_edge_angle (double) – See
tube_shape. Acceptable values are [0.0, 90.0], otherwise closer extreme is used. If less than 0.0, this check is skipped. Default value -1.merge_connected_barrels (int) – Option to merge connected barrels. 0 for detecting connected barrels separately and 1 for detecting the connected barrel as one single hole. Default value is 1.
min_cone_angle (double) – The inward facing normal direction of all faces comprising the wall of the tube must make this angle with respect to the primary axis. The primary axis is between the centers of the rims. If less than or equal to 0.0, this check is skipped. A value of 45.0 is recommended. Default value 0.0.
min_planar_dim (double) – Applied to each rim. The minimum planar dimension of the tube must exceed this value. If less than or equal to 0.0, this check is skipped. Default value 0.0.
min_height (double) – The distance between the center of the rims must exceed this value. If less than or equal to 0.0, this check is skipped. Default value 0.0.
Example#
Detect tubes of any shape in all surfaces in the model and write the tube 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_holedetectionsettubeparams(tube_shape=31, tube_type=0) model.hm_holedetectionfindholes(find=6) # For tubes (2D/3D) we need to set find=6 _, result = model.hm_holedetectiongetnumberofholes() num_tubes = result.numberOfHoles if num_tubes > 0: holesfile.write(f"Number of tubes = {num_tubes}\n\n") for n in range(num_tubes): holesfile.write(f"Queried data details of tube {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("Tubes not detected.\n") model.hm_holedetectionend() holesfile.close()