Hi
Is there a way to select a polysurface and iterate through the faces to find the face or faces that are the largest in area?
Eric
Hi
Is there a way to select a polysurface and iterate through the faces to find the face or faces that are the largest in area?
Eric
Hi @eric.bunn,
below script extracts the brep face with largest area, note that it can take a while to calculate:
ExtractLargestBrepFace.py (920 Bytes)
_
c.
This will definitely work for me. Thank you.
Eric
Clement
Can you explain what this line of code does?
maximum, index = System.Double.MinValue, -1
rs.Prompt(“Calculating, please wait”)
Also, is their a way to return the bounding box information for the largest face as well?
Eric
Hello,
This line is setting two variables. Maximum is being initialised to the closest thing to negative infinity before each loop looks for a larger value. Index is being initialised to -1 as a sentinel value. If it is still -1 after the loop then something went wrong…
Graham
see the explanation of @Dancergraham, you can also write it in two lines eg:
maximum = System.Double.MinValue
index = -1
Yes, once you have the index of the largest brep face you can get it and return it’s bbox:
face = brep.Faces[index]
bbox = face.GetBoundingBox(True)
Note that this will give you an axis aligned boundingbox. To add it to the document you can use:
scriptcontext.doc.Objects.AddBrep(bbox.ToBrep())
scriptcontext.doc.Views.Redraw()
_
c.
Thanks again Clement. This will also work for me.
Eric