Hi, I am working on some mesh tools in python and have not found any ways to handle preselected mesh edges or faces, Is it possible?
below allows preselection of mesh faces from multiple meshes:
import Rhino import scriptcontext import rhinoscriptsyntax as rs def GetMeshFaces(): go = Rhino.Input.Custom.GetObject() go.SetCommandPrompt("Select mesh faces") go.GeometryFilter = Rhino.DocObjects.ObjectType.MeshFace go.SubObjectSelect = True go.EnablePreSelect(True, True) go.EnableClearObjectsOnEntry(False) get_rc = go.GetMultiple(1, 0) if not go.CommandResult() == Rhino.Commands.Result.Success: return if get_rc == Rhino.Input.GetResult.Object: for objref in go.Objects(): print "Mesh Id:", objref.ObjectId print "Face Index:", objref.GeometryComponentIndex.Index go.Dispose() if __name__=="__main__": GetMeshFaces()
To get mesh edges in the same way, just change the GeometryFilter:
go.GeometryFilter = Rhino.DocObjects.ObjectType.MeshEdge
Thanks, I feared I had to use Rhino Common…
It’s a Common problem
Do not fear Rhino Common. Once you start using it, its a big timesaver in many situations.
You can start working with geometry without ever adding it to the document.
So no worries about ‘garbage’ collection or undo trouble.
I admit that custom object selections like the example above are overwhelming and easy to want to keep away from.
However as per example here, it’s this type of customization Rhino Common has to offer in addition to pre-canned script-syntax methods.
Oh, and here I hoped I didn’t need to invest more time into more complex programming, I have spent enough hours as it is My mind can handle it, but my memory can’t… it’s stuffed up there!