The error is from c=c.append(rs.AddRectangle(plane, x, y ))
As @byxor commented, and should simply be c.append(rs.AddRectangle(plane, x, y ))
There are several other issues with the code that may cause side effects based on your stated goal.
a=rs.AddRectangle( plane, x, y )
is assigned but not used. If you are scripting in grasshopper and using a
as the default output, you will only get a single rect as a result.
plane = rs.RotatePlane(plane, i+2.0, [0,0,1])
is re-using plane
so you will get a double increment with i+2.0
(prior rotation plus new rotation). This is not necessarily wrong, but a bit less intuitive than i*2
.
d=rs.MoveObject(c[i],(0,0,1))
moves your item, but d
is not returned and is overwritten by the next iteration. Also, you are moving all items to the same location and if you want increasing movement, you need an incrementor like (0,0,1*i)
.
Bellow is an example that is a bit more clear, and assumes X
,Y
are float
and U
is a int
with a
the grasshopper script component output.
Working Example:
#Imports.
import rhinoscriptsyntax as rs
#Set the work plane.
plane = rs.WorldXYPlane()
#Create Output Array.
c=[]
#Create rectangles.
for i in range(u):
#Rotate by increasing increments
newPlane = rs.RotatePlane(plane, i*2.0, [0,0,1])
#Create rectangle.
rect = rs.AddRectangle(newPlane, x, y )
#Move rectange by increasing increments.
rs.MoveObject(rect,(0,0,1*i))
#Add final rectangle to output list.
c.append(rect)
#Return final List.
a = c