Rs syntax - custom_filter


#1

Full of questions today… :smiling_imp:

What does the custom_filter argument in rs.GetObject(s) do and how does one use it? Not much help from the Help… :smile:

Thx, --Mitch


(Menno Deij - van Rijswijk) #2

Looping at the code at https://github.com/mcneel/rhinopython/blob/master/scripts/rhinoscript/selection.py#L190

the custom_filter is a funtion that returns True or False and takes as input
RhinoObject, Geometry, ComponentIndex


(Steve Baer) #3

Here’e a very basic sample using the custom_filter argument to only allow selection of “circles” in your GetObject routine

import rhinoscriptsyntax as rs

def circle_filter(rhino_object, geometry, component_index):
    return rs.IsCircle(geometry)

obj = rs.GetObject("select circle", custom_filter=circle_filter)
if obj:
    rs.SelectObject(obj)

#4

OK, thanks Steve, very useful, need to integrate that into my usual routines!
–Mitch