I am writing simple script to multiply the zones to specified height (z-axis) specified times.
I get error Runtime error (TypeErrorException): iteration over non-sequence of type Brep at rs.CopyObject is executed. Since I don’t expect iteration happens at this code, I have no idea what is wrong. Can anyone tell me the reason? Below is the code.
import rhinoscriptsyntax as rs
def floorMultiplier(zone,height,number):
building=[zone]
for i in range(1,number+1):
print (i)
print (type(zone))
temp=rs.CopyObject(zone,[0,0,height*i]) <=I get error at this point
building.append(temp)
return building
AllZones=floorMultiplier(TypicalFloor,FloorHeight,FloorNumber)
Are you running this in GH? It doesn’t error out in the normal Rhino script editor if I throw in some pseudo values for TypicalFloor(a brep object id) ,FloorHeight (number), FloorNumber (number)…
Maybe you need to provide us with the GH def and the inputs. Did you check your input access parameters and type hints?
Thank you for your reply.
Please find rhino file and GH file with the FloorMultiplier component including the error. 180207CopyObject.gh (10.4 KB) 180207copyObject.3dm (66.0 KB)
the definition, in this state, only works in V6. This is why:
in V6, we added code to the rs.CopyObject() function so that it allows to also directly work on RhinoCommon brep’es. Earlier, it was only able to work with rhinoscriptsyntax Guids.
the previous bullet point implies that, if you change the Type Hint to rhinoscriptsyntax geometry/Guids, it will always work, both in V5 and V6.
In general, especially in V5, if you work with rhinoscriptsyntax, it’s best to input geometry with its corresponding Type Hint: rhinoscript Guids. In V6 we added code in many places to allow more mixing.
Here is your definition, with the more specific Type Hint:
Hi Giulio,
Hmm, this is interesting - I assume it works also with rhinoscriptsyntax methods running as a normal script outside Grasshopper? Do you have a list somewhere of rs methods that can now accept RhinoCommon objects (breps, curves, etc)?
Of course, if one wants to remain backwards-compatible, I guess this is to be avoided for now…