I find this very useful because it returns the selection point. unfortunately it doesn’t allow subobjects.
Is there any other way to get the selection point with GetObject ?
Or to pick subobjects with GetObjectEx?
Thanks
I find this very useful because it returns the selection point. unfortunately it doesn’t allow subobjects.
Is there any other way to get the selection point with GetObject ?
Or to pick subobjects with GetObjectEx?
Thanks
Probably have to roll your own on this one - if you have the selection point from GetObjectEx, you can figure out which Brep face it landed on (Brep.IsPointOnFace()
) and then sub-select the face…
yes, something like that.
But why GetObjectEx doesn’t accept subobjects?
Dunno - not a programmer…
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def GetSubobjectPickPt():
sel=rs.GetObjectEx("Pick a polysurface object",16)
if not sel: return
objID=sel[0] ; pick_pt=sel[3]
tol=sc.doc.ModelAbsoluteTolerance
rhobj=rs.coercerhinoobject(objID)
brep=rhobj.Geometry
for face in brep.Faces:
rc, u, v = face.ClosestPoint(pick_pt)
if rc:
face_pt=face.PointAt(u,v)
if face_pt.DistanceTo(pick_pt)<tol:
if face.IsPointOnFace(u,v)==Rhino.Geometry.PointFaceRelation.Interior:
rhobj.SelectSubObject(face.ComponentIndex(),True,True,True)
rs.AddPoint(pick_pt)
GetSubobjectPickPt()