Surely I’m overlooking something simple here. Given all the very complicated stuff I do with RhinoCommon and Python, I’m not sure why this is whipping me so hard. Below is a code sample and the results I’m getting vs the results I want. The CreateFromSweep is giving crooked results. The Sweep.PerformSweep is not making anything (and empty array is returned).
#! python 2
import Rhino.Geometry as rg
import scriptcontext as sc
import math
radius1 = 0.5
radius2 = 1.3
radius3 = 1
# set to True to test the SweepOneRail() method,
do_sweep = False
section = rg.Circle(0.5).ToNurbsCurve()
section.Rotate(math.radians(90), rg.Plane.WorldXY.YAxis, rg.Point3d.Origin)
section.Translate(rg.Vector3d(0, radius1 + radius2, 0))
sc.doc.Objects.AddCurve(section)
rail = rg.Ellipse(rg.Plane.WorldXY, radius3, radius2).ToNurbsCurve()
sc.doc.Objects.AddCurve(rail)
if do_sweep:
# PRODUCES NOTHING
sweeper = rg.SweepOneRail()
brep = sweeper.PerformSweep(rail, section)[0]
sc.doc.Objects.AddBrep(brep)
else:
# PRODUCES AN UNEXPECTED (CROOKED) RESULT
brep = rg.Brep.CreateFromSweep(rail, section, True, 0.001)[0]
sc.doc.Objects.AddBrep(brep)
Ok, I can get this to work, but why? How is this different except creating the circle on it’s own plane. Is that it? We can’t move/rotate the circle into place after creating it? (But oddly, iirc, I was always able to get a fine result if I rotated/moved the circle into the side position, but I get this crooked result if I moved it to the end).