Macro for _SelBrushCurves?

I wonder if it’s possible to make a macro similar to how the _SelBrushPoints command works, except that it will filter out the object types to be able to brush-select only curves, then (after a right-click to confirm the selection) switch back to the previous selection filter?

The following commands in Rhino would help a lot, but they don’t exist:
_SelBrushCurves
_SelBrushSurfaces
_SelBrushPolysurfaces
_SelBrushMeshes
_SelBrushSubD

Or, what about upgrading the existing _SelBrush tool to be able to pick the type of geometry to be brush-selected? Rhino should remember that during the current session.
I use the following settings for the _SelBrush tool now, but unfortunately it will select any type of geometry.
( Curve SelectionMode=Crossing BrushWidth=40 Polyline=No SelectThroughObjects=No RealTimeSelection=Yes )

Hi Bobi - you can do this with a script:

! -RunPythonScript (
import rhinoscriptsyntax as rs
import Rhino

x = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()
y = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()

x.GlobalGeometryFilter = Rhino.DocObjects.ObjectType.Curve

Rhino.ApplicationSettings.SelectionFilterSettings.UpdateFromState(x)

rs.Command("SelBrush")

Rhino.ApplicationSettings.SelectionFilterSettings.UpdateFromState(y)

)

In the bigger picture though, I’d prefer to come up with a way to hand any selection tool a command-only set of filters via a macro to making a bunch of specialized commands.

-Pascal

1 Like

Hi @pascal , would you be kind enough to convert that to a downloadable script, please? I struggle to find out how to make this run on my Rhino 7 via Rhino Python editor. It returns the following message when I try:

File “D:\PROGRAMI\Rhinoceros 7\Добавки\Brush select\BrushSelectCurves.py”, line 1
! -RunPythonScript (
^
SyntaxError: unexpected token ‘!’

Hi Bobi- the whole thing is a macro that runs the script - you can put that on a button. As a standalone script, use the part between the top and bottom parens.

SelBrushCurves.py (419 Bytes)

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"

-Pascal

1 Like

Wow, I didn’t knew that it was a macro. Usually the macros I make are far simpler. :slight_smile: I just tried your macro and it works exactly as it should. Is there a way to prevent the Selection filter from appearing each time after the macro is run?

I don’t think so.

-Pascal

OK, then I will live with that. It’s still a helpful tool to select the curves via brush. Thanks again!

I wish that it was a native selection tool in Rhino, so that it would not evoke the Selection filter. :slight_smile: Maybe Rhino 9 can have it. Is it possible to make a macro that closes the Selection filter automatically right after running the macro for brush selection of curves?

I also tried your Python script and strangely it selects only surfaces this time around. So, I basically have two different brushes now: one for curves (the macro) and one for surfaces (the script). :smiley:


EDIT: I actually made it work this way by adding the last line rs.Command("SelectionFilter"):

! -RunPythonScript (
import rhinoscriptsyntax as rs
import Rhino

x = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()
y = Rhino.ApplicationSettings.SelectionFilterSettings.GetCurrentState()

x.GlobalGeometryFilter = Rhino.DocObjects.ObjectType.Curve

Rhino.ApplicationSettings.SelectionFilterSettings.UpdateFromState(x)

rs.Command(“SelBrush”)

Rhino.ApplicationSettings.SelectionFilterSettings.UpdateFromState(y)

rs.Command(“SelectionFilter”)
)


EDIT 2: The Python script also worked! Here is what I changed:

_-RunPythonScript “D:\PROGRAMI\Rhinoceros 7\Добавки\Select curves by brushing\SelBrushSurfaces.py” _Pause _SelectionFilter

Hi @pascal ! I just made a short video overview of both scripts that you made, in order to make them more popular among the Rhino community. I also placed a link to your YouTube channel in the video description.

1 Like

I have a youtube channel?? Ah, OK- Rhino! :upside_down_face:

-Pascal

1 Like

Ha-ha, I just searched for your name and the first result was this one. :smiley: I didn’t knew that it’s a common account for the whole Rhino staff.

@Rhino_Bulgaria - in case you want to play some more, here are a couple of more flexible versions- I think they work…

-Pascal

1 Like

Hi @pascal ! I tried the first macro and looks like the “Filter=SurfaceOrPolysurface” option does not work on my Rhino. Filtered points and curves work, though. Not sure why the surfaces and polysurfaces can’t be selected via window crossing.

Another thing to notice is that the “Filter=ControlPoint” option actually selects any type of geometry. Strange. :slight_smile:


By the way, I modified your 2nd macro this way, in order to make it work in my Rhino 7 and automatically close the “Selection filter” window:

! -RunPythonScript (
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)

rs.Command("SelectionFilter")
)