AddSweep1 Function, Incorrect Output - Need help debugging

Hey everyone!

I’m attempting to use the addsweep1 function to take a circle object and sweep it around a given figure. See the picture below


The expected output should look something like:


However, when I run the addsweep1 command from my script, I get the following:


Here’s a snippet of the addsweep1 code I’m running:

rs.AddSweep1(figure_curve, [circle])

Any insights?

Are you saying it works with the normal Rhino Sweep1 command and not with AddSweep1()?
Can you post the input curves? I suspect that the problems are a combination of the possibility that your figure curve might be a polycurve with non-tangent joints as well as the fact that the circle radius is too large to go around some of the sharp bends without folding…

(oh, and if the profile is just a circle, why don’t you use pipe?)


Yeah, the Rhino function Sweep1 works and not the rhinoscriptsyntax function doesn’t. Here’s the sequence I use to get to this point. The input curve is read in using the import command.

# Import object from file 
join_string = str(input_directory + filename)
combined_string = '!_Import ' + '"' + join_string + '"'

# Get all objects imported 
objs = rs.LastCreatedObjects(select=False)[0]

# Close curve
closed_curve = rs.CloseCurve(objs, 0.25)

# Rebuild curve to create smoother shape
rs.RebuildCurve(closed_curve, 3, 100)

# # Sweep function to create "tubed" object
circle = rs.AddCircle(rs.WorldZXPlane(), 0.5)
points = rs.CurvePoints(closed_curve)
center_point = rs.CircleCenterPoint(circle)
moved_circle = rs.MoveObject(circle, [points[50][0], points[50][1], -1 * center_point[2]])
rs.AddSweep1(closed_curve, [moved_circle])

I actually haven’t tried piping it! Take a look at the code and see if it makes sense.
I can clarify if need be but essentially the logic is:

Import the figure shape, close the curve, rebuild it so it’s smoother, and then use the circle to sweep the figure.

Can you post the curve though? Hard to test without an example to test on…

Ok! Here is the attached .3dm file.

test.3dm (2.7 MB)

Yep, I certainly fails spectacularly here - I have no explanation why though… You could try with AddPipe():


It will be slightly different, as your circle is not perpendicular to your profile in the sweep example…
Plus, you will still have the “folding” at the sharp turns, no matter what…


Hi Ebe,

Your result looks like the circle is not positioned on the curve. Furthermore I suspect the circle is not on or near the curve start point.

I’m replying from my phone so this is speculation.

Also note that rs.CurvePoints returns control points, these will not be on the curve.

I would try and:
Get the perpendicular frame at the curve start point.
Create the circle on that plane and perform the sweep1.


It’s near (center about 0.04mm from being on the curve), I checked it… Rhino’s native Sweep1 command works fine with the circle as placed. As I replied, AddPipe with the same radius works fine in this case


I guess I should add, that while I wouldn’t necessarily script it this way myself, I think it should work.

Hey! So I’ve been using the AddPipe command and it works great! Now, I have to let you in on what I’m actually trying to do.

I want to be able to export the piped object as an stl file but for now it doesn’t work. In the past, my sweep command (which I did manually) allowed me to create a frame that I would then export as an .stl file and then 3D print it.

Is there a better way to be able to 3D print this object? Using AddPipe doesn’t allow me to export the object as an .stl file.

The error I get when I try to export is “No surface object to export”

How are you exporting? It exports here fine just using _Export (STL) with my test file. As the original is folded in the tight corners, the STL might need some fixing before 3D printing, but it does export correctly. (1.6 MB)