Model.hm_holedetectionsetentities#
- Model.hm_holedetectionsetentities(collection)#
Adds entities to find holes in. Can be called multiple times with different entity types/selections and each call appends to any previous selections. Selections are cleared on any call to
Model.hm_holedetectioninit()/Model.hm_holedetectionend().This must be preceded by a call to
Model.hm_holedetectioninit().- Parameters:
collection (Collection) – The collection containing the entities to find holes in. Valid entity types are components, surfaces, solids, and elements. If a collection of components is defined, both geometry and FE are considered.
- Returns:
hwReturnStatus- Status object
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()