AddSweep1: Cannot apply it

The Code I am typing for the problem is:
There are several curves given.I have to select all the curves,then only one cross-sectional area,which is also given.Then all the curves will follow sweep command with that cross-sectional area.

I have been only able to copy the cross-sectional area to the curves,but cannot apply addsweep1 to all the curves.I just now want to follow the sweep command for all the curves.I am attaching the figure before and after running the code.Can you apply the sweep1 command for all the curves in the code?

Thank you.

My code:
import rhinoscriptsyntax as rs
ptlst =

rod = rs.GetObjects(“Select rods”,4)
shape = rs.GetObjects(“Select cross sectional area”,4)
shapelst = rs.DivideCurve(shape,1,True,True)

for r in rod:
ptlst += rs.DivideCurve(r,1,True,True)

for i in range(0,len(ptlst),2):

start = shapelst[0]
end = ptlst[i]

translation = end-start
rs.CopyObject(shape, translation )

something like this could work, assuming your curves start at z=0 in your example:

import rhinoscriptsyntax as rs

def make_sweeps():
    curves = rs.GetObjects ("select sweep rails",4)
    profile = rs.GetObject ("select profile curve",4)
    if curves and profile:
        for curve in curves:
            origin =rs.coercecurve(profile).ToNurbsCurve().PointAtStart
            start = rs.coercecurve(curve).PointAtStart
            trans = start-origin
            rs.MoveObject(profile, trans)
            rs.AddSweep1(curve, [profile], closed=False)
if __name__ == "__main__":

1 Like

Thank you,sir!
Thank you very much.It worked.

Can you explain the code in short?Mainly the functions = {coercecurve(profile),ToNurbsCurve(),PointAtStart,MoveObject()}

Thanks again.

to get the startpoint of a polyline, I first convert the rhino object to a curve (coercecurve)
then to a nurbscurve (ToNurbsCurve)
because only the latter has the method (.PointAtStart) that I wanted to use

1 Like