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