Is there a way to limit object selection by a name filter in rhinoscript or rhinocommon for a Python function?
I have a set of objects with the following name format 0.vertex.0, 0.vertex.1, 1.vertex.1, 1.vertex.2, which I can see when I call rs.ObjectName(objectid). I’d like to have a wildcard filter such that only objects with 0.* can be selected (a custom filter by name).
Rhinoscript allows this for standard object geometries, i.e. the following script:
objectids = rs.GetObjects("Pick some objects", rs.filter.curve)
will not allow me to even select points.
However, I haven’t found a good example of a custom filter for rs.GetObjects.
I’d like to define a custom filter as follows:
def name_filter(RhinoObject, name): obj_name = rs.ObjectName(RhinoObject) if name == obj_name: return True return false
name = '0.Vertex.0' objectids = rs.GetObjects('Select vertices', custom_filter=name_filter(name))
Apologies for the formatting, I don’t know how to create proper indented blocks.
Does the custom_filter have to have three arguments (and only 3), as indicated in the documentation (rhino_object, geometry, component_index)? Is it possible to also pass the name wildcard to the custom_filter function?
The few examples I’ve found using custom filters also did not work as scripts for me (https://stevebaer.wordpress.com/2010/07/22/starmaker-an-advanced-sample/), where I still received an objectid for points despite a custom_filter existing for closed polylines.