REmaking surfaces fast?

See attached.

I’m looking to replace this procedure with something faster (I’m quite familiar with Rhino scripting):

  1. Trace over the surface corners with Polyline
  2. Set CPlane to the new Polyline
  3. PlanarSrf the new Polyline
  4. ShrinkTrimmedSrfToEdge the new surface
  5. Delete the old surface and the Polyline

If your borders are linear, DupBorder, SimplifyCrv, PlanarSrf… delete original.

Select Pause
SetRedrawOff DupBorder
SelPrev Delete SelLast
SimplifyCrv PlanarSrf Delete

Does that do it?


SimplifyCrv is what I was looking for!! Thanks, Pascal! I’ll just implement that method in my script instead of fixing the surfaces, so I don’t even have to spend any extra time.

Although, it works for the most part, sometimes it still leaves 1 knot where it’s supposed to remove it. See attached. Asterisk Surfaces.3dm (39.6 KB)

That happens when the start/end of the curve is there rather than on a corner point- these do not get simplified out, though it seems like maybe that would not be too hard.


I made it work by “cycling” the curve with explode+join commands. This all can be marked as solved. :smiley:

Sub SurfaceREbuilder()

Dim Surface, Surfaces, CLayer, check
CLayer = Rhino.CurrentLayer 

Surfaces = Rhino.GetObjects("Pick surfaces to rebuild", 8,, True)
If IsEmpty(Surfaces) Or IsNull(Surfaces) Then Exit Sub
Rhino.EnableRedraw False

For Each Surface In Surfaces
	check = 0
	Rhino.CurrentLayer Rhino.ObjectLayer(Surface)
	Do While check = 0
		Call Cycler(Surface, check)

Rhino.CurrentLayer CLayer
Rhino.EnableRedraw True

End Sub

Function Cycler(ByRef SRF, ByRef CHK)
Dim Border, crvsA, crvsB
Border = Rhino.DuplicateSurfaceBorder(SRF, 1)(0)
Rhino.SelectObject Border
Rhino.Command"EXPLODE", False
crvsA = Ubound(Rhino.LastCreatedObjects)
Rhino.Command"JOIN", False
Border = Rhino.FirstObject
Rhino.Command"SIMPLIFYCRV", False
Rhino.Command"PLANARSRF", False
Rhino.SelectObject Rhino.FirstObject
Rhino.Command"ShrinkTrimmedSrfToEdge", False
Rhino.DeleteObject Border
Rhino.DeleteObject SRF
SRF = Rhino.FirstObject
Border = Rhino.DuplicateSurfaceBorder(SRF, 1)(0)
Rhino.SelectObject Border
Rhino.Command"EXPLODE", False
crvsB = Ubound(Rhino.LastCreatedObjects)
If crvsA = crvsB Then CHK = 1
Rhino.Command"JOIN", False
Rhino.DeleteObject Rhino.FirstObject
End Function