Last active
November 23, 2023 23:53
-
-
Save pgolay/5bb928a58ddfc37a7f1ac135ff279734 to your computer and use it in GitHub Desktop.
A filtered version of the SelBrush command.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import rhinoscriptsyntax as rs | |
import Rhino | |
import scriptcontext as sc | |
x = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState() | |
y = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState() | |
types = [Rhino.DocObjects.ObjectType.Point, | |
Rhino.DocObjects.ObjectType.PointSet, | |
Rhino.DocObjects.ObjectType.Grip, | |
Rhino.DocObjects.ObjectType.Curve, | |
Rhino.DocObjects.ObjectType.Brep, | |
Rhino.DocObjects.ObjectType.Mesh, | |
Rhino.DocObjects.ObjectType.SubD, | |
Rhino.DocObjects.ObjectType.InstanceReference, | |
Rhino.DocObjects.ObjectType.Annotation, | |
Rhino.DocObjects.ObjectType.Hatch, | |
Rhino.DocObjects.ObjectType.Light, | |
Rhino.DocObjects.ObjectType.ClipPlane | |
] | |
typeList = ["Point", "PointCloud", "ControlPoint", | |
"Curve","SurfaceOrPolysurface", | |
"Mesh", "SubD","Block", | |
"Annotation", "Hatch", | |
"Light","ClippingPlane"] | |
idx = 3 | |
if 'SELECTION_INDEX' in sc.sticky: | |
idx = sc.sticky['SELECTION_INDEX'] | |
go = Rhino.Input.Custom.GetOption() | |
go.SetCommandPrompt("Set a filter. Press Enter to accept the current default.") | |
go.AddOptionList("Filter", typeList, idx) | |
rc = go.Get() | |
print(rc) | |
if rc==Rhino.Input.GetResult.Option: | |
idx = go.Option().CurrentListOptionIndex | |
sc.sticky["SELECTION_INDEX"] = idx | |
x.GlobalGeometryFilter = types[idx] | |
Rhino.ApplicationSettings.SelectionFilterSettings.UpdateFromState(x) | |
rs.Command("_SelBrush") | |
Rhino.ApplicationSettings.SelectionFilterSettings.UpdateFromState(y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment