Need help with AddSweep1

I’ve written a script to extrude a curve along a path. I pick the path curve, insert a block at the start point of that curve, explode the block so it is a curve, then extrude that curve along the path:

ExtrudePath = rs.GetObject(“Pick the path”)
sp = rs.CurveStartPoint(ExtrudePath)

rs.InsertBlock( StiffenerBlock, sp, (1,1,1), 0 )
stiff = rs.FirstObject()

stiff = rs.FirstObject()

rs.ExtrudeCurve(stiff, ExtrudePath)

I would like to do the same thing to sweep along 1 rail. I use the same code to define the path and shape but at the end use:

rs.AddSweep1(SweepPath, stiff)

But this doesn’t work. I get the message: iteration over non-sequence of type Guid

However, if I add the line:
shape = rs.GetObjects(“Select stiffener”)
and select the exploded block, then:
rs.AddSweep1(SweepPath, shape)
it works. And this only works with GetObjects (plural) and not GetObject.

Can anyone please help me with this?

rs.AddSweep1(SweepPath , [stiff])
Should work, given your error message

1 Like

Thanks! That worked. What do the brackets do?

The “brackets” create a list. A list is a basic python structure. Lots of info in the python online docs about lists.

@ckline You should perhaps also look at the rhinoscriptsyntax help file for the method, which gives you a lot of info, as well as start to understand what python error messages mean - they are actually quite succinct as well as helpful in debugging.


Unfortunately, @dale, @steve, @dan the new online help is not nearly as helpful as the old chm help, which specifically spells out that it wants a list:


@ckline The python error message is also telling you the same thing - although a bit more arcanely:

iteration over non-sequence of type Guid

Which simply means it expects something to iterate over like a list or a tuple (a “container” for one or more items), but it only got one item not in a container - a single GUID of one object - which is not “iterable”, so the method didn’t know what to do - so you got that error message.

1 Like

I would also argue the function could get smarter and create a list on the fly if only a single guid is supplied, especially since the documentation states a single guid would be a valid input.

I agree here. Right now the line that accepts the shape argument reads like this:

shapes = [rhutil.coercecurve(shape, -1, True) for shape in shapes]

but it could be something like this:

if isinstance(shapes,System.Guid): shapes=[shapes]
shapes = [rhutil.coercecurve(shape, -1, True) for shape in shapes]