AddSweep1 Function, Incorrect Output - Need help debugging


(Ebe Farooqui) #1

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

46%20PM

The expected output should look something like:

57%20PM

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

57%20PM

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

rs.AddSweep1(figure_curve, [circle])

Any insights?


#2

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?)

–Mitch


(Ebe Farooqui) #3

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 + '"'
rs.Command(combined_string)

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

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

# 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.


#4

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


(Ebe Farooqui) #5

Ok! Here is the attached .3dm file.

test.3dm (2.7 MB)


#6

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

rs.AddPipe(closed_curve,rs.CurveDomain(closed_curve)[0],0.5)

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…

–Mitch


(Willem Derks) #7

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.

HTH
-Willem


#8

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

image

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


(Ebe Farooqui) #9

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”


#10

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.

pipe.zip (1.6 MB)