siemen
September 19, 2018, 8:21pm
1
Hi guys,
draw any single face surface in rhino and run this with python:
import rhinoscriptsyntax as rs
rs.GetObjects(“Select objects”, 16)
The selection filter is set to 16 which refers to Polysurfaces. Why is it still possible to select a single face surface?
Willem
(Willem Derks)
September 19, 2018, 8:31pm
2
Indeed,
Looking at __FiterHelper in selection.py it’s obvious that 16 will filter Breps thus not excluding Surfaces
If you use 2097152 as filter, it works as expected.
-Willem
def __FilterHelper(filter):
geometry_filter = Rhino.DocObjects.ObjectType.None
if filter & 1:
geometry_filter |= Rhino.DocObjects.ObjectType.Point
if filter & 16384:
geometry_filter |= Rhino.DocObjects.ObjectType.Grip
if filter & 2:
geometry_filter |= Rhino.DocObjects.ObjectType.PointSet
if filter & 4:
geometry_filter |= Rhino.DocObjects.ObjectType.Curve
if filter & 8:
geometry_filter |= Rhino.DocObjects.ObjectType.Surface
if filter & 16:
geometry_filter |= Rhino.DocObjects.ObjectType.Brep
if filter & 32:
geometry_filter |= Rhino.DocObjects.ObjectType.Mesh
if filter & 512:
geometry_filter |= Rhino.DocObjects.ObjectType.Annotation
if filter & 256:
geometry_filter |= Rhino.DocObjects.ObjectType.Light
if filter & 4096:
geometry_filter |= Rhino.DocObjects.ObjectType.InstanceReference
if filter & 134217728:
geometry_filter |= Rhino.DocObjects.ObjectType.Cage
if filter & 65536:
geometry_filter |= Rhino.DocObjects.ObjectType.Hatch
if filter & 131072:
geometry_filter |= Rhino.DocObjects.ObjectType.MorphControl
if filter & 2097152:
geometry_filter |= Rhino.DocObjects.ObjectType.PolysrfFilter
if filter & 268435456:
geometry_filter |= Rhino.DocObjects.ObjectType.Phantom
if filter & 8192:
geometry_filter |= Rhino.DocObjects.ObjectType.TextDot
if filter & 32768:
geometry_filter |= Rhino.DocObjects.ObjectType.Detail
if filter & 536870912:
geometry_filter |= Rhino.DocObjects.ObjectType.ClipPlane
if filter & 1073741824:
geometry_filter |= Rhino.DocObjects.ObjectType.Extrusion
return geometry_filter
siemen
September 19, 2018, 8:47pm
3
Hi Willem, thanks for helping out. Could you explain how you found out? Where do I find this __Filterhelper or selection.py?
Willem
(Willem Derks)
September 19, 2018, 9:26pm
4
On my phone so no screenshots but:
On the line where rs.Get… is written, Click in the left margin of the textfield editor. You’ll see a red dot appear. That’s a breakpoint. If you now run the script it will halt at that line. In the upper bar arrow icon buttons appear that let you step skip etc… Through the code.
If you “step in” it will open the scriptfile rs.GetObject() is in. In the method a call to __FilerHelper() is made and if you keep stepping in the code you’ll get there .
Does this makes sense?
-Willem
EDIT:. Found older post with images:
Yes,
Have a look at these screenshots from the editor.
You can click at the position of the red dot to insert a breakpoint.
This will halt the script at that point and you can inspect the content of the current variables:
[image]
[image]
[image]
More to find on rhinocommon:
https://developer.rhino3d.com/api/RhinoCommon/html/N_Rhino.htm# !
search for plane for example:
[image]
[image]
A good way to explore working with rhino common in python is to insert breakpoints before a rhino…
1 Like
siemen
September 19, 2018, 10:01pm
5
Now that’s useful info. Thanks a lot, Willem!
1 Like
siemen
September 20, 2018, 3:27pm
6
@pascal is this supposed to be like that or is it a bug?
pascal
(Pascal Golay)
September 20, 2018, 3:37pm
7
Hi Siemen - the actual 16 filter is for a brep which does include single surface breps- as far as I know all of this is as expected, though I understand the possible confusion. Similarly 16 allows extrusion objects to be selected - you can also filter those explicitly - this was a more deliberate decision though, I believe, in not, where possible, differentiating breps from extrusions.
-Pascal
siemen
September 20, 2018, 3:41pm
8
Then I suggest changing the info on the page I linked to above from
“16 Polysurface or multiple-face”
to
“16 Brep”
1 Like