import Rhino
import scriptcontext
import System.Guid
import rhinoscriptsyntax as rs
def PickMeshFace():
# get the mesh face from rhino viewport
PickMeshFace = Rhino.Input.Custom.GetObject()
PickMeshFace.GeometryFilter = Rhino.DocObjects.ObjectType.MeshFace
PickMeshFace.SetCommandPrompt("Select Mesh Face")
PickMeshFace.Get()
if PickMeshFace.CommandResult()!=Rhino.Commands.Result.Success:
return gs.CommandResult()
# Rhino.Input.Custom.GetObject .Object() to Rhino.DocObjects.ObjRef
objref = PickMeshFace.Object(0)
return objref
def GetFaceIndex(objref):
# Rhino.DocObjects.ObjRef .GeometryComponentIndex to Rhino.Geometry.ComponentIndex
MeshFaceIndex = objref.GeometryComponentIndex
return MeshFaceIndex.Index
Face_1_Ref = PickMeshFace()
print "This is the mesh ID"
print Face_1_Ref.ObjectId
print "This is the Rhino.Geometry.Mesh "
print Face_1_Ref.Mesh()
print "This is the Face index"
print GetFaceIndex(Face_1_Ref)