[Python] How to check for type Polysurface?

If I have:

s = rs.GetObjects("Select Panel",rs.filter.surface+rs.filter.polysurface)

#how can I check if "s" is a surface or a polysurface?
if s is Rhino.Geometry. - > # there's no Polysurface type here!

Hi Ivelyn,

Not near my computer right now so can’t be too specific, but I believe s is a list of objects, so you need to iterate over its members to test for type.


I think you’re looking for Brep.IsSurface property.

import rhinoscriptsyntax as rs
s = rs.GetObject("Select Panel",rs.filter.surface+rs.filter.polysurface)
s = rs.coercegeometry(s).ToBrep()
if s.IsSurface:
    print "it is a surface"
    print "it is not a surface"

P.S. you need to add .ToBrep() to make it work on extrusions.

1 Like

Yes, kind of. I just saw there is rs.IsPolysurface

Yep actually

s = rs.GetObjects("Select Panel",rs.filter.surface+rs.filter.polysurface)
if not s: return
for i in range(0, len(s)):
    o = rs.coercebrep(s[i])
    if o.IsSurface:
        print 'Obj ', s[i], ' / ', o, 'is surf'
        print 'Obj ', s[i], ' / ', o, 'is polysurf'

rs.IsPolysurface(s as guid)
this saves the conversion :wink:

1 Like

Yes, abstracts the coercebrep for cleaner code. Well found.