i'm going to script a code to get 2 dimension and draw a rectangel then repeat that u-times by rotating and moving it.and present all rectangels.. i've wrote this:
#start
import rhinoscriptsyntax as rs
#set the work plane
plane = rs.WorldXYPlane()
#draw a rectangel
a=rs.AddRectangle( plane, x, y )
#set a module to repeat rectangels
c=[]
for i in range(u):
plane = rs.RotatePlane(plane, i+2.0, [0,0,1])
c=c.append(rs.AddRectangle(plane, x, y ))
d=rs.MoveObject(c[i],(0,0,1))
it declare this error:
Runtime error (TypeErrorException): 'NoneType' object is not subscriptable
Traceback:
line 13, in script
how i can fix it?
The error is from
c=c.append(rs.AddRectangle(plane, x, y ))As @byxor commented, and should simply bec.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 usingaas 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-usingplaneso you will get a double increment withi+2.0(prior rotation plus new rotation). This is not necessarily wrong, but a bit less intuitive thani*2.d=rs.MoveObject(c[i],(0,0,1))moves your item, butdis 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,YarefloatandUis aintwithathe grasshopper script component output.Working Example: