Iteration over non-sequence of type Brep for rs.CopyObject

ghpython

#1

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)

#2

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?

–Mitch


#3

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)


(Giulio Piacentino) #5

Hi @Katsuya_Obara

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:

180207CopyObject-gh-hints.gh (10.4 KB)

I hope this helps,

Giulio


Giulio Piacentino
for Robert McNeel & Associates
giulio@mcneel.com


#8

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…

Thx, --Mitch


(Giulio Piacentino) #9

Any method that inherently uses TransformObject/TransforObjets will now work:
https://mcneel.myjetbrains.com/youtrack/issue/RH-38298

The list of V6 changes for GhPyton can be seen on YouTrack.

The list of transformable types is here: https://github.com/mcneel/rhinoscriptsyntax/commit/d4c5c5e4c7d6270615848995b9a076ea3289ec22 (in addition to anything derived from Rhino.Geometry.GeometryBase)