Hi,
I was wondering if someone would be able to help with this ongoing issue I face.
I work on several of my clients models for work and am constantly checking surface area. The models I work on have 1000’s of surfaces and can be very complex. I find many issues when calculating the area, and my only current solution is to explode all surfaces and check the area in small groups of surfaces at a time, until I can hone in on the error surface. I then have to hide/delete this surface and re-check area. Some models can have multiple error surfaces over a model, so this process can take some time.
Does anyone have a command to find these error surfaces instantly? I run “Select bad surfaces” to remove any potential error’s but usually these surfaces causing the area issue do not come up.
Any help on this issue would be great.
Thanks
It’s possible to script some detection of this - perhaps first just the brep (polysurface) that contains one or more bad faces, and then perhaps can be refined to find which face(s). Would be good to have an example or two to test, because I don’t know what exactly the area calculation will return as a result if it fails…
Here’s a starting point script that highlights bad objects and calculates the total area of remaining objects.
import rhinoscriptsyntax as rs
def get_area():
surfaces = rs.GetObjects("surfaces", 8+16, preselect=True)
if not surfaces:
print("Cancel")
return
total_area = 0
failed = []
for surface in surfaces:
result = rs.SurfaceArea(surface)
if result is None:
failed.append(surface)
continue
area, error_bound = result
total_area += area
print("Total area: {}".format(total_area))
if len(failed) > 0:
rs.UnselectAllObjects()
rs.SelectObjects(failed)
if len(failed) == 1:
print("Area calculation failed for this object.")
else:
print("Area calculation failed for these {} objects.".format(len(failed)))
Please follow this link to download a model which contained surfaces which contains error surfaces:
This is a simple model which contains one radius surface causing issues, usually models I work with are much bigger and takes longer to find this error.
I believe most of my clients work with Rhino, but there could be a translation error from other softwares.
Please follow this link to download a model which contained surfaces which contains error surfaces:
This is a simple model which contains one radius surface causing issues, usually models I work with are much bigger and takes longer to find this error.
I believe most of my clients work with Rhino, but there could be a translation error from other softwares.
Here is my version. It detects and selects two single surfaces in your file above whose area calculation fails.
I extended it to include checking for individual faces in joined polysurfaces which cause the area calculation of the whole object to fail. You can test this by joining all your surfaces into two polysurfaces and then running the script.
I don’t really know how to best indicate where those faces are, so I ended up just duplicating them into individual surfaces and coloring them red - plus reporting on the command line. The script doesn’t remove the bad faces from the polysurfaces (I guess that could be done though), it simply adds new duplicate (red) faces in the same location and selects them, so you can know where they are. Up to you then to fix the original objects, the duplicated faces will need to be deleted manually. There are maybe better ways to do this.