Model.hm_flangedetectionfindflanges#
- Model.hm_flangedetectionfindflanges(find)#
Runs the flange detection functions for finding flanges based on input entities and parameters. This must be preceded by calls to
Model.hm_flangedetectioninit(), andModel.hm_flangedetectionsetparams().- Parameters:
find (int) –
Bit value defining the types of flanges to find (Bit0 + 2*Bit1):
Bit0
0 - Do not find 2D flanges
1 - Find 2D flanges
Bit1
0 - Do not find 3D flanges
1 - Find 3D flanges
Show Bit value calculator
Radio Button Table Option Name Value Find 2D flanges (Bit0) Find 3D flanges (Bit1) Calculated argument value: 0 - Returns:
hwReturnStatus- Status object
Example#
Find 2D flanges from elements in all components , use a min width of 2 , a max width of 20 and a feature angle of 20 , and write out all flange details to a file named C:/temp / flanges.txt#import hm import hm.entities as ent model = hm.Model() flangesfile = open("C:/temp/flanges.txt", "w") comps = hm.Collection(model, ent.Component) model.hm_flangedetectioninit(collection=comps) model.hm_flangedetectionsetparams(max_width=20.0, min_width=2.0, feature_angle=20.0) model.hm_flangedetectionfindflanges(find=1) _, result = model.hm_flangedetectiongetnumberofflanges() n=result.numberOfFlanges if n > 0: flangesfile.write(f"Number of flanges = {n}\n") flangesfile.write("Flanges details \n") for i in range(0,n): _, result = model.hm_flangedetectiongetflangedetails(index=i) entityType = result.entityType dimension = result.dimension detectionType = result.detectionType flangeEntityIDs = result.flangeEntityIDs freeBoundaryEntityIDs = result.freeBoundaryEntityIDs connectedBoundaryEntityIDs = result.connectedBoundaryEntityIDs minWidth = result.minWidth maxWidth = result.maxWidth length = result.length hasHoles = result.hasHoles isInfinite = result.isInfinite Details = [ entityType, dimension, detectionType, flangeEntityIDs, freeBoundaryEntityIDs, connectedBoundaryEntityIDs, minWidth, maxWidth, length, hasHoles, isInfinite ] flangesfile.write(f"details = {Details}\n") print(i) status, result = model.hm_flangedetectiongetflangemidline(index=i,offset_distance=5.0) print("pointCoordinates",result.pointCoordinates) Coordinates = result.pointCoordinates for points in Coordinates: midPoint=points.midPoint flangesfile.write(f"midline = {midPoint}\n") model.hm_flangedetectionfindmates(max_search_dist=10.0, min_search_dist=0.0) _, result = model.hm_flangedetectiongetnumberofmatinggroups() m = result.numberOfMatingGroups if m>0: for i in range(0,m): _,result = model.hm_flangedetectiongetmatinggroupdetails(index=i) matingGroupDetails = result.matingGroupDetails for details in matingGroupDetails: memberType = details.memberType memberContents = details.memberContents flangesfile.write(f"memberType = {memberType}\n") flangesfile.write(f"memberContents = {memberContents}\n") else: flangesfile.write("Flange mates not detected.\n") else: flangesfile.write("Flanges not detected.\n") model.hm_flangedetectionend() flangesfile.close()