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
c.
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.
-Willem
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!
HI it look very well, but I seem just can select the meshface in wireframe (yellow color), but I can not
select in shading situation?
Hi @jerry1, it still seems to work over here using Rhino 7 or 8.
Do you see something different ?
_
c.
thanks for your answer, but if I wish use brush to select? does it can implement?
whether I need set some program?
Hi @jerry1, above script is for (pre)selection of mesh faces, it doesn’t care how these faces where selected by the user. Do you want to brush select faces per script or can show an example of what you’re trying to do ?
_
c.