Option Explicit 'Script by Mitch Heynick 'Version 07 July, 2013 Rhino.AddStartUpScript Rhino.LastLoadedScriptFile Rhino.AddAlias "Planarize4SideSrfs", "_NoEcho _-Runscript (Planarize4SideSrfs)" 'Call Planarize4SideSrfs() Sub Planarize4SideSrfs() Dim origSrfs,srf,bords,pts,plane,xform,projPts(3),i origSrfs=Rhino.GetObjects("Select 4 edged surfaces to planarize",8,,True) If Not IsArray(origSrfs) then Exit Sub Call Rhino.EnableRedraw(False) For each srf in origSrfs bords=Rhino.DuplicateSurfaceBorder(srf,1) pts=Rhino.PolylineVertices(bords(0)) Call Rhino.DeleteObjects(bords) If Ubound(pts)=4 Then Redim Preserve pts(3) plane=Rhino.PlaneFitFromPoints(pts) xform=Rhino.XformPlanarProjection(plane) For i=0 to 3 projPts(i)=Rhino.PointTransform(pts(i),xform) Next Call Rhino.AddSrfPt(projPts) End If Next Call Rhino.EnableRedraw(True) End Sub