Delete points in the middle of straight edges of a surface

Hi all,
I am generating different geometries starting from squared cells. Once I find the cells and I join them to get the shape I want, I would like to get right of the points between my corners. I am looking for a way to do this in rhinocommon and python if possible. This is what I get, you can see the midpoints on the edges due to the generation from smaller cells:

For now, I was just able to do get rid of those points using the Discontinuity component. So, I implemented it in my code like this after picking the cells:

import Rhino.Geometry as rg
import ghpythonlib.components as gh
joinedCells = rg.Brep.JoinBreps(cells, 0.01)[0] # put [0] to get one brep, otherwise it is an Array[Brep]
# use three lines to delete inner edges and keep only countour curve and create surface from that
nakedEdges = joinedCells.DuplicateNakedEdgeCurves(True, False)
curveFromEdges = rg.Curve.JoinCurves(nakedEdges, 0.01, True)[0]
curveNoMidPoints = gh.PolyLine(gh.Discontinuity(curveFromEdges, 1)[0], True) # this line to avoid having points in the middle of a straight line
surfaceFromCurve = rg.Brep.CreatePlanarBreps(curveNoMidPoints , 0.01)[0]

As you can see from the picture below I don’t have those points anymore. But I would like to solve this issue by using rhinocommon.

If you are generating the surfaces from planar polylines and trying to get rid of points between collinear segments, use Curve.Simplify()

Hi @Helvetosaur. Thank you very much for your reply. I tried to implement your suggestion by changing the last two lines of my code but I am not getting the output I am looking for. I still have the midpoints. Probably I used the method in the wrong way.

curveFromEdges.Simplify(rg.CurveSimplifyOptions.All , 0.01, 1.0)
surfaceFromCurve = rg.Brep.CreatePlanarBreps(curveFromEdges, 0.01)[0]

The curve is not simplified in place, instead a new simplified copy is returned.

simplified_crv=curveFromEdges.Simplify(rg.CurveSimplifyOptions.All , 0.01, 1.0)
1 Like

Thank you @Helvetosaur !! Now it perfectly works.