How to get a surface of a filleted rectangle via RhinoCommon?

Actually, I’d like to build a flat rectangular surface with all corners filleted to the same radius. What would be the proper way to achieve this? While reviewing the Surface class, I couldn’t find a fillet option. Perhaps I should first fillet the polyline (rectangle) and then create the surface from it, but I’m not sure how to do that. Can someone help me?

Hi Vitaly, below is a quick example without error checking (for too large radius etc):

import Rhino
import scriptcontext
import rhinoscriptsyntax as rs

def DoSomething():
    
    plane = Rhino.Geometry.Plane.WorldXY
    rect = Rhino.Geometry.Rectangle3d(plane, 40, 20)
    
    crv = rect.ToNurbsCurve()
    tol = scriptcontext.doc.ModelAbsoluteTolerance
    ang_tol = scriptcontext.doc.ModelAngleToleranceRadians
    
    pc = Rhino.Geometry.Curve.CreateFilletCornersCurve(crv, 5.0, tol, ang_tol)
    breps = Rhino.Geometry.Brep.CreatePlanarBreps(pc)
    
    scriptcontext.doc.Objects.AddBrep(breps[0])
    scriptcontext.doc.Views.Redraw()
    
DoSomething()

_
c.

4 Likes

Much obliged @clement ! This is exactly what I searched for.

I looked for a bunch of stuff on how to make a filleted rectangle, but I didn’t find this - thanks @clement !