GetSelectedObjectTypes return 16 for surfaces

Hi all!

As from here https://developer.rhino3d.com/api/RhinoCommon/html/T_Rhino_DocObjects_ObjectType.htm
surface type should return 8.
But through c# it returns 16:
A = this.RhinoDocument.Objects.GetSelectedObjectTypes().GetHashCode();
2020-04-03 20_36_55-Window

Why so? Is this a bug?
Considering it might be a list of mixed Surfaces and Breps , so I need to distinguish the cases from: only surfaces (8), only breps (16) and mixed surfaces and breps (24).
Any workaround?

Thanks everyone in advance!

with some extra code, yes there is a workaround
Brep has a IsSurface property you can use to filter you selected objects
beware that a trimmed surface is actually a Brep

…it would be nice that GetSelectedObjectTypes() can return a finer grained class/type

1 Like

Yes, with more coding.
But with a large selection I need to iterate through all objects, cast to geometry, cast to brep (if it is a brep), and finally i’m doing
bool isSurf = brep.Faces.Count() == 1;
to detect if it is a “non-polysurface” …
But this all is quite heavy… i think.

… and bug-free.

I mean, I’m trying to use as simple as possible surfaces and it always return 16 … I am not able to trigger it to return 8.

The type returned on the top level object is a brep so you do need to check the face count - if 1, then it is a ‘surface’ in the Rhino sense, but not as RhinoCommon sees it - it is still a brep until you dig down to the faces.

-Pascal

It’s been years since last time i made rhinoscripts… but i still remember and i tested:

-runscript (
sub test

surf=rhino.getObject ("Select a surface", 8)

end sub
test
)

(https://developer.rhino3d.com/api/rhinoscript/selection_methods/getobjects.htm)
This script still let you only select surfaces (trimmed or not, whatever), and not brep faces or anything else.
I would call “bug” what on my first post… if not that, surely there is some incoherence in the libraries…

I mean, there is some other hidden/deep method for this?
Or even rhino with his “Select surface” functions is checking face count every time?
(I’m asking just out of curiosity by now…)

Anyway, if there aren’t any other workaround, i’ll work with face count for now. No problem.

Thanks for the help!

Yep, but in RhinoscriptSyntax at least - I can’t tell in Rhino Script - the function does exactly that - gets the brep and then counts the faces and returns 8 if it is one. I think the main thing is that under the hood, Rhino deals with breps at the top level (of geometry) and surfaces are components within these - sometimes only one.

   rhobj = rhutil.coercerhinoobject(object_id, True, True)
    geom = rhobj.Geometry
    if isinstance(geom, Rhino.Geometry.Brep) and geom.Faces.Count==1:
        return 8 #surface
    return int(geom.ObjectType)

-Pascal

1 Like