Model.hm_holedetectiongetnumberofmates#
- Model.hm_holedetectiongetnumberofmates()#
Returns the number of found hole/tube mating ‘groups’. This must be preceded by a call to
Model.hm_holedetectionfindmates().- Returns:
hwReturnStatus- Status objectHmQueryResult- Result object containing the output values:numberofMates (int)
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()