Hi! What is the correct way to find an object type in a list? None of these approaches seem to work. In the examples I am trying to find a plane with ‘selectedObjs’ containing a plane and a box.
Code:
selectedObjs = rs.GetObjects(“Select objects”)
#First approch
if rs.ObjectsByType(8) not in selectedObjs:
print “Fail”
else:
print “Success”
#Second approch
if rs.ObjectType(selectedObjs) == rs.ObjectsByType(8):
#do something
A plane surface and a box are of the same basic object type - BREP - however, you can distinguish between them because the plane is a single surface and the box is a polysurface. The first is object type 8 or rs.filter.surface, the second is object type 16 or rs.filter.polysurface. There are also the methods rs.IsSurface() and rs.IsPolysurface().
import rhinoscriptsyntax as rs
objs = rs.GetObjects("Select objects")
for obj in objs:
if rs.IsSurface(obj):
#do something
elif rs.IsPolysurface(obj):
#do something else
else:
#do who knows what
or
import rhinoscriptsyntax as rs
objs = rs.GetObjects("Select objects")
for obj in objs:
obj_typ=rs.ObjectType(obj)
print obj_typ #will print a list of numbers representing the object types
2 Likes