Quantcast
Channel: Scripting - McNeel Forum
Viewing all articles
Browse latest Browse all 5793

Iterate over list of guids error

$
0
0

@jackshaftoe wrote:

I’m trying to convert all polysurfaces to blocks for export to sketchup but the code exits with error “iteration over non-sequence of type Guid”.

import rhinoscriptsyntax as rs
import System.Guid

#objs = rs.GetObjects("Select Objects") #, filter = rs.filter.surface)

objs = rs.ObjectsByType(16, False)
print("Types", type(objs), type(objs[0]), objs[0] == System.Guid, objs[0] == str)

for obj in objs:
    point = (0, 0, 0)  # rs.GetPoint("Block base point")
    #objGuid = rs.coerceguid(obj)
    #print("type GUID: ", type(ogjGuid), objGuid == System.Guid)
    #objList = list(obj)
    block = rs.AddBlock(obj, point, None, True)
    rs.InsertBlock(block, point)

The script works when passing objs as a list of Guids (without for loop) to the addBlock function, turning all polysurfaces into a single block. The addblock definition actually says that the function takes an array as first parameter but trying to put the Guid into list within the for loop ends also with error “Guid is not iterable”
Hints are much appreciated, thanks.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 5793

Trending Articles