Problems with addsweep1

hi guys,

i´va a problem with addsweep1.
i don´t know why the following script isn´t working.
i simply want to sweep a circle along a spiral.

need help.

nice greets.

Here is the script:

import rhinoscriptsyntax as rs
import math

point0 = (0,0,0)

point1 = (100,0,0)

pitch = 1.5

turns = 5

radius0 = 5

radius1 = 2

rail = rs.AddSpiral(point0, point1, pitch, turns, radius0, radius1)

r = 0.5

shapes = rs.AddCircle( [0,radius0,0], r )

rs.AddSweep1 (rail, shapes, closed=False)

Instead of this:

rs.AddSweep1(rail, shapes, closed=False)

do this:

rs.AddSweep1(rail, [shapes], False)

wow, it works!
thank you verry much!!


Hi Samphi and Dale,

I am trying to do the same thing.
But i have a list of 8 curves to go in as “shapes”.
causing this Message: Parameter must be a Guid or string representing a Guid.
I checked and the list does contain the system Guid’s of the 8 shapes
I am not using the [ ] since it is already a list.

profiles = rs.SelectedObjects()


rs.Command('_Circle 0,0,0 _R ' + str(ringsize) + " _Enter")

curve = rs.SelectedObjects()



It runs, but there is no sweep.

Hope someone can help me.



Can you provide a file with your “shapes” (profiles)? --Mitch

i want to make the ring sort of wave in and out. so i made 2 profiles. with varying width. then rotate them so every 45 degrees the profile alternates.

rs.Command("_-New _None")
intRingsize = rs.GetString(“Ringsize”)
ringsizeInput = float(intRingsize)
ringsize = ((ringsizeInput/math.pi)/2)
intWidth = rs.GetString(“Width”)
width = float(intWidth)
global width
intTop = rs.GetString(“Height”)
top = float(intTop)
global top
intBottom = rs.GetString(“Bottom”)
bottom = float(intBottom)
global bottom
intThickness = rs.GetString(“Thickness”)
thickness = float(intThickness)
global thickness

#create profile
#Sets the name of the object and returns the GUI id
def setObject(object, objectName) :
rs.ObjectName(object, objectName)
return rs.ObjectsByName(objectName)

def createProfile():
start = 0,width/-2,0
startBottom = 0,width/-2,thickness * -1
topPoint = 0,0,top
end = 0,width/2,0
endBottom = 0,width/2,thickness * -1
bottomValue = 0,0,bottom*-2
thicknessOne = 0,width/-2,thickness*-1
thicknessTwo = 0,width/2,thickness*-1
startTwo = 0,width/2,0
W = (rs.AddInterpCurve([start, topPoint, end]))
X = (rs.AddInterpCurve([startBottom, bottomValue, endBottom]))
Y = (rs.AddCurve([start, thicknessOne]))
Z = (rs.AddCurve([startTwo, thicknessTwo]))


joinedCurveOne = rs.JoinCurves([W,X,Y,Z],delete_input=True)
rs.RotateObject(joinedCurveOne,(0,0,0), 90,None, copy=True)
rs.RotateObject(joinedCurveOne,(0,0,0), 180,None, copy=True)
rs.RotateObject(joinedCurveOne,(0,0,0), 270,None, copy=True)


def waveProfile():
widthOfWave = width + 4
start = 0,widthOfWave/-2,0
startBottom = 0,widthOfWave/-2,thickness * -1
topPoint = 0,0,top
end = 0,widthOfWave/2,0
endBottom = 0,widthOfWave/2,thickness * -1
bottomValue = 0,0,bottom*-2
thicknessOne = 0,widthOfWave/-2,thickness*-1
thicknessTwo = 0,widthOfWave/2,thickness*-1
startTwo = 0,widthOfWave/2,0
W = (rs.AddInterpCurve([start, topPoint, end]))
X = (rs.AddInterpCurve([startBottom, bottomValue, endBottom]))
Y = (rs.AddCurve([start, thicknessOne]))
Z = (rs.AddCurve([startTwo, thicknessTwo]))
joinedCurveTwo = rs.JoinCurves([W,X,Y,Z],delete_input=True)



rs.RotateObject(joinedCurveTwo,(0,0,0), 45,None, copy=False)
rs.RotateObject(joinedCurveTwo,(0,0,0), 90,None, copy=True)
rs.RotateObject(joinedCurveTwo,(0,0,0), 180,None, copy=True)
rs.RotateObject(joinedCurveTwo,(0,0,0), 270,None, copy=True)

def createCircle():
profiles = rs.SelectedObjects()

a = profiles[0]
b = profiles[1]
c = profiles[2]
d = profiles[3]
e = profiles[4]
f = profiles[5]
g = profiles[6]
h = profiles[7]
profilesStr = [a,b,c,d,e,f,g,h]

rs.Command('_Circle 0,0,0 _R ' + str(ringsize) + " _Enter")
curve = rs.SelectedObjects()

#rs.Command("_Sweep1 _Enter _C")
#macro = "!_Sweep1 _Enter _ClosedSweep=True"
#rs.Rhino.RhinoApp.RunScript(macro, True)




It´s still alot messy, so sorry for that
also at the bottom there is me trying different things out

this is driving me nuts.

joinedCurveOne = rs.JoinCurves([W,X,Y,Z],delete_input=True)


joinedCurveThree = rs.RotateObject(joinedCurveOne,(0,0,0), 90,None, copy=True)

joinedCurveOne is a guid. but joinedCurveThree is not, apperently

joinedCurveOne =

System.Guid object at 0x000000000000002D [6fcfdc77-1372-47df-998d-7b3c1d4987b2]>

joinedCurveThree = 632c38ef-7ff2-4cff-aa0d-796afd2eed0b

how and when do i know if it’s a guid or not. or even a guid in the right format

First, look at the Help file to see what a method returns (outputs). JoinCurves() can result in more than one output curve, therefore it will always return a list - of object ID’s (GUID)

If the original curves are not joinable, they are returned anyway. So unless something really went wrong, you should always have a list of GUIDs. If there was some major problem, you might get a return of None however.

If there is just one GUID in the list, you can access it by using my_list[0].

rs.RotateObject() only works on one object at a time, therefore it returns only one GUID, not a list - as it can never result in more than one object.

HTH, --Mitch

Hi Mitch,
I do have a list of GUID but it will give me an error message so i took a different approach
Been looking at this all day so i have tried many thing, and i have ery basic knowledge as you might have noticed (A)

I just want to create the profiles, select all, and use them as my list of GUID

I got it going in a way.

It just flips it when i use all profiles though
even though they are constructed (copied) from the same, also the seams point the same way

When i sweep1 the profiles and curve manually in the command line it works

Thank you for you input, it’s quite clear, i already made separate variables for every rotated (and copied) profile. combining them at the end. Rhino.AddSweep1(curve, my 8 variable,True)

i just had to put it in between to make the method read it as GUID rather then string
joinedCurveEight = rs.RotateObject(joinedCurveFive,(0,0,0), 270,None, copy=True)
global profile8
profile8 = [joinedCurveEight]



so i changed the code alot by now. my input can be totally free now. but, it still makes this weird inverted sweep as shown in the pictuere. anyone has an idea? with my old script the sweep would work if i had a specific total height for the profile but this doesn’t seem to influence the outcome anymore.

if anyone has experience with the addsweep1 script please let me know. or perhaps someone can help me to use command line for sweep 1 and help me navigate through the pop up window



Ok, so the seam of the curve didn’t start at the first profile. now it works.

Hello Guys,

I am trying to set the intStyle to Roadlike.

rs.AddSweep1(myspiral,[myLine], closed=False)

How can I add intStyle?

I tried:
rs.AddSweep1(myspiral,[myLine], closed=False, intStyle=1)

rs.AddSweep1(myspiral,[myLine], closed=False,1)

rs.AddSweep1(myspiral,[myLine], closed=False, style=1)

Can anybody help me, please?

The short answer is “You can’t”. rs.AddSweep1() uses a RhinoCommon method Brep.CreateFromSweep that does not have any of the roadlike options. You would need to create a custom RhinoCommon function that uses the Rhino.Geometry.Sweep1Rail class which does accept roadlike direction arguments. I don’t have time now to write an example, but if nobody else answers, I will look at it later.