How to loft Circle through RhinoCommon?

rhinocommon
python

#1

Maybe this question is kind of simple but it really troubles me a lot.
ArcCurve type should be inherited from Curve type. But why curve can generate brep through “Rhino.Geometry.CreateFromLoft” , while circle as ArcCurve type can not?

Here’s the code

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg

circle_1 = rs.coercecurve(c1)
circle_2 = rs.coercecurve(c2)

brep = rg.Brep.CreateFromLoft([circle_1,circle_2], circle_1.PointAtStart, circle_2.PointAtStart, rg.LoftType.Normal, True)
brep = rg.Brep.CreateFromLoft([circle_1,circle_2], rg.Point3d.Unset, rg.Point3d.Unset, rg.LoftType.Normal, True)

For both brep, I got empty Array[Brep](()).

Is there anyway to convert ArcCurve into Curve? I only find how to convert ArcCurve type into NurbsCurve type, and still failed to get loft with NurbsCurve - type - circle. And it can’t construct a new curve through Rhino.Geometry.curve(circle).

Or how to get loft shape with circle in RhinoCommon?


#2

The following works

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc

c1=rs.GetObject("Select a circle",4)
c2=rs.GetObject("Select a circle",4)

circle_1 = rs.coercecurve(c1)
circle_2 = rs.coercecurve(c2)
no_pt=rg.Point3d.Unset
norm_loft=rg.LoftType.Normal

breps = rg.Brep.CreateFromLoft([circle_1,circle_2],no_pt,no_pt,norm_loft,False) #False
new_IDs=[sc.doc.Objects.AddBrep(brep) for brep in breps]
sc.doc.Views.Redraw()

If you pass True for a closed loft above it fails, because you need at least 3 section curves:
From the online API for Loft:

"Constructs a closed surface, continuing the surface past the last curve around to the first curve. Available when you have selected three shape curves. "

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg
import scriptcontext as sc

c1=rs.GetObject("Select a circle",4)
c2=rs.GetObject("Select a circle",4)
c3=rs.GetObject("Select a circle",4)

circle_1 = rs.coercecurve(c1)
circle_2 = rs.coercecurve(c2)
circle_3 = rs.coercecurve(c3)
no_pt=rg.Point3d.Unset
norm_loft=rg.LoftType.Normal

breps = rg.Brep.CreateFromLoft([circle_1,circle_2,circle_3],no_pt,no_pt,norm_loft,True)
new_IDs=[sc.doc.Objects.AddBrep(brep) for brep in breps]
sc.doc.Views.Redraw()

The above works with 3 circles.

HTH, --Mitch


#3

That’s very helpful!! Thank you Helvetosaur.
I was mixed the final option - closeloft with closeCap. That’s why I set this True before. Yeah , 2 crvs can’t generate a 3Dloop. I was focused on the input type but forget the closeloft options. Sorry.


#4

Yeah, understandable. Just use brep.CapPlanarHoles() to close the ends if they are planar.

–Mitch