I’m trying to get the edges of a planar surface that should be a rectangle, so I’m expecting a return of 4 edges. For some of the geometry I’m dealing with however, I’m getting 5 edges (my guess is due to a tolerance issue), which causes problems for the rest of my script. Is there a good way to “force” my brep to only have 4 edges (i.e. approximate as a rectangle if it is slightly off)?
strips = rs.ObjectsByLayer('CSA')
for strip in strips:
# get only surfaces
if rs.IsSurface(strip):
if rs.IsSurfacePlanar(strip):
strip_brep = rs.coercebrep(strip)
edges = Rhino.Geometry.Brep.DuplicateEdgeCurves(strip_brep)
print(len(edges))
I discovered that the input geometry that was used to initially construct the surface (and then the Brep) consisted of a polyline made of 6 points (4 corners and 2 midpoints). I’m not sure why the construction of the Brep then resulted in 5 edges instead of 6 based on that information (I don’t know how much information is “stored” when creating a planar surface about the input polyline). So the initial workaround is just to adjust the polyline so it only is composed of the 4 corner points, which gives me the desired number of brep edges (4).