Model.hm_flangedetectiongetflangemidline#
- Model.hm_flangedetectiongetflangemidline(index, offset_distance, max_chordal_deviation=0.1)#
Returns offset boundary points for a given flange. This must be preceded by a call to
Model.hm_flangedetectionfindflanges().The midline points are returned as a list of triples. These coordinates can then be used to construct the mideline.
- Parameters:
index (int) – The index of the flange to query, starting from 0.
offset_distance (double) – The offset distance from the free boundary.
max_chordal_deviation (double) – The chordal deviation used to coarsen the output. Default value 0.1.
- Returns:
hwReturnStatus- Status objectHmQueryResult- Result object containing the output values:pointCoordinates (
HmQueryResultList)-Result list object containingHmQueryResultobjects with the following output data:midPoint (numpy.ndarray)
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()