Python script problem with sweep2

Hey, guys! I have problems with the sweep2 command in python script. Pic 1 shows my idea to generate the model with the sweep2 and the command I used is “rs.AddSweep2([arc_guide1, guideline1], shapes, False)”.

U can find that in pic 2 with manual operation it worked very well, the edges were smooth and beautiful.

While when I used the python script, the edges were jagged and not smooth at all.

Please if there be any ideas to solve the problem, as I must use the script because I have to generate hundreds of models with different parameters :frowning:

Can you post a sample set of curves to try? Oh, and that situation looks like it might be better to use Loft with just the cross section curves…

This is the script, thank you! parametric model (3.3 KB)

OK, I see the result is different, will need to look at how the AddSweep2 function in rhinoscriptsyntax is set up. You might need to go through RhinoCommon in this case.

Just as a test here, using


instead of AddSweep2() seems to make a nice clean surface - especially since your curves are all parametrically generated and thus have a similar structure.

Wow! That’s pretty cool! One reason I didn’t choose loft was that at the end of the shape, the face edges might not be vertical to the reference plane. But now I think just add the number of the planes may fix this problem. Thanks a lot, anyway~ :grinning:

Hello here!

I’ve got a similar problem here with Rhino 7 and the python script rs.AddSweep2. I suspect there is a bug somewhere in the pipeline, since
A) This works with Rhino 5 (not 6)
B) This also works with Rhino 7 in ‘manual mode’, in the main UI using the Sweep2 command.

Here is the case:

AddSweep2_FailsWithRhino7.3dm (613.4 KB)

And the test code:

ReRead_curve1 = rs.ObjectsByLayer(“curve1”, False)
ReRead_curve2 = rs.ObjectsByLayer(“curve2”, False)
ReRead_cross_sections = rs.ObjectsByLayer(“cross_sections”, False)

wall = rs.AddSweep2((ReRead_curve1, ReRead_curve2), ReRead_cross_sections, closed=True)

And the result is:

Thank you!

Hi @Alexandre_Filiatraul,

Flip the direction of your two rail curves.

– Dale

Thank you Dale, very appreciated!

Another part to the question: Your suggestion effectively corrects the test case I sent, by not the original issue it come from. It seems that writing those curve on layers has modified them. After having read them, their domain has changed. Is it something you have heard about?

Thanks again!


Hi @Alexandre_Filiatraul,

If your adding curves to a Rhino document, and then later querying them and finding the domains have changed, then please provide me a code sample so I can repeat what you are seeing.


– Dale

Hi Dale,

After several tests, the problem is clearer to me: I now see no Rhino bug; all domains remain the same.

The only thing is: rs.AddSweep2 is harder to use than the manual version in the UI, since the curve seams must be aligned, direction matched, and cross-sections must be ordered accordingly.

My first bug-correction trial really worked by accident: writing the cross_sections on a layer, I (without knowing) reversed the order, making the whole thing work.

My bug was the following; after ordering cross-sections, I set the curveSeams precisely at the beginning (and end) of the first cross-section, creating a kind of limit-condition (not sure about the correct formulation here, in english!); while it would be much safer to set them mid-way between the first and last cross-sections.

Problem solved: thanks again for your help!