rs.GetObject, return SubDFace Type?

I was trying to drill down into the methods for SubDFace / Edge / Vertex. rs.GetObject only seems to return <type ‘SubD’> , even if you subobject select a face. How do I bridge this gap to constructing something from these other classes?

import Rhino
import rhinoscriptsyntax as rs
import scriptcontext

subd_id = rs.GetObject("Select a SubD Object", subobjects= False )
subd_obj = rs.coercerhinoobject( subd_id )
subd_geom = subd_obj.Geometry

subobject_id = rs.GetObject("Subobject select something", subobjects=True)
subobject_obj = rs.coercerhinoobject( subobject_id )
subobject_geom = subobject_obj.Geometry

print type(subobject_geom)
print type(subd_geom)

Returns:
<type ‘SubD’>
<type ‘SubD’> ( even if I subobject select a face / edge / vertex )

@DavidLeon ?

Hi @Jonathan_Hutchinson
You can access those classes as properties of your selected SubD, wheather its the whole SubD or just the selected face: https://developer.rhino3d.com/wip/api/RhinoCommon/html/T_Rhino_Geometry_SubD.htm

Can you perhaps give an example of what you are trying to accomplish?

Thanks as always David. I can return any/all the Faces in a SubD with the SubD.Faces property with no issue.

I’m wondering how I get a SubD Vertex/Edge/Face (in)directly from a Get method. Maybe I need a different type of ObjRef?

At the moment for ComponentIndexType of a returned ComponentIndex, I’m getting InvalidType rather than, what I think I should expect:

#SubdVertex  71  Targets a SubD vertex pointer Id
#SubdEdge    72  Targets a SubD edge pointer Id
#SubdFace    73  Targets a SubD face pointer Id
import Rhino
import rhinoscriptsyntax as rs
import scriptcontext

subd_id = rs.GetObject("Select a SubD Object", subobjects= False )
subd_obj = rs.coercerhinoobject( subd_id )
subd_geom = subd_obj.Geometry

subobject_id = rs.GetObject("Subobject select (ctrl+shift) something", subobjects=True) #subobj return is diff
subobject_obj = rs.coercerhinoobject( subobject_id ) # Rhino.DocObjects.ObjRef 
subobject_geom = subobject_obj.Geometry

print subd_geom.Faces, "\n", subd_geom.Faces.Count, "picked SubD Faces"
print subobject_geom.Faces, "\n", subobject_geom.Faces.Count, "picked Subobject Faces"

print subd_geom.ComponentIndex(), subd_geom.ComponentIndex().ComponentIndexType, "SubD ci Type"
print subobject_geom.ComponentIndex(), subobject_geom.ComponentIndex().ComponentIndexType, "Subobj ci Type"

It’s with the aim of Trying to get SubDFace.LimitSurfaceCenterPoint() on a picked Face. I’m just testing on a primitive sphere.

Solved, I think:

I got to it eventually by using the result of rs.GetObject (subobjects=True). I didn’t realise that rhinoscriptsyntax actually returns something of type Rhino.DocObjects.ObjRef - and not only the GUID. So there was more detail within that simple ‘Get’ I could drill down into. Although I’m not sure how I’d do it with RhinoCommon if I did need to be more explicit.

If True, subobjects can be selected. When this is the
case, an ObjRef is returned instead of a Guid to allow for tracking

subobject_id = rs.GetObject( "Pick again", False, subobjects=True )
print subobject_id.GeometryComponentIndex.ComponentIndexType
print subobject_id.GeometryComponentIndex.Index

Glad you figured it out @Jonathan_Hutchinson. rhinoscriptsyntax is a wrapper for RhinoCommon, which means, everything is RC under the hood. Take a look at this really helpful tool that allows you to see the code underneath rhinoscriptsyntax. For instance, if you look into the rs.GetObject() functions, it´ll help you understand how to get objects more explicitly using RhinoCommon directly.