Brush or Lasso selection for mesh faces from RhinoCommon?

Hi All,

While searching the RhinoCommon API reference I did not find any reference to brush or lasso selection in the Rhino.Input or Rhino.Input.Custom namespaces. I assume that this functionality is currently only available in the GUI?

In that case, any pointers to implement a similar functionality via RhinoCommon would be sincerely appreciated!



The GUI provided by the Lasso command is not available in RhinoCommon. But you should be able to select objects by polygon using RhinoDoc.FindByRegion? Does this help?

Thanks, I’ll try implementing it using ObjectTable.FindByCrossingWindowRegion() and FindByWindowRegion() as I assume that’s what you meant.

Yes, sorry. Thanks for the correction.

Hi again, I’m still having some trouble selecting mesh faces using this method.

I’m drawing a circular brush in the OnDynamicDraw() method of a custom GetPoint class, and using ObjectTable.FindByCrossingWindowRegion() to select objects within the circular region. However, that last method is not so keen on giving me mesh faces (it always returns an empty array). Are there any additional steps i must take to make mesh faces eligible candidates for being returned by this method?

This is the code:

protected override void OnDynamicDraw(Rhino.Input.Custom.GetPointDrawEventArgs e)
                // Draw a circle around the cursor
                Plane brush_plane;
                bool res = e.Viewport.GetFrustumNearPlane(out brush_plane);
                if (!res)
                var brush_circle = new Circle(brush_plane, e.CurrentPoint, this.brushRadius);
                e.Display.DrawCircle(brush_circle, System.Drawing.Color.Cyan);

                if (this.isIndicating)
                    var brush_bounds = NurbsCurve.CreateFromCircle(brush_circle).DivideEquidistant(2.0);
                    RhinoObject[] faces = e.RhinoDoc.Objects.FindByCrossingWindowRegion(e.Viewport, brush_bounds, true, ObjectType.MeshFace);
                    foreach (RhinoObject face in faces)
                        // Just a small test for debugging purposes:
                        ComponentIndex[] ids = face.GetSelectedSubObjects();
                        // TODO: add valid faces to collection

Thanks all!


Addendum: I tried the same with transformation of the bounds to screen coordinates, but it still yields an empty array. If i set the filter to ObjectType.AnyObject, I do get the Mesh as a result.

var bounds_list = new Rhino.Collections.Point3dList(brush_bounds);
Transform xf = e.Viewport.GetTransform(Rhino.DocObjects.CoordinateSystem.World, Rhino.DocObjects.CoordinateSystem.Screen);

The region selection function (i.e. FindByRegion, FindByWindowRegion, FindByCrossingWindowRegion) return top-level RhinoObject objects. So, subobject filters are not going to work. Can I assume you wan to “lasso” select a bunch of faces from a large, single mesh?

Can I assume you wan to “lasso” select a bunch of faces from a large, single mesh?

Yes Dale, that’s right. I’m looking for lasso or brush selection to select a bunch of faces in a contiguous region (preferably only visible faces). Thanks for the response.

Hi Dale,

I have recently run into the need to window select mesh faces, but only want to get mesh faces that are visible in the current view (i.e., not completely obstructed by other geometry in the scene). Is there any practical way to do this for mesh faces in RhinoCommon? Thanks, Larry

Hi Larry,

Does this C++ sample help you in any way?

– Dale

I guess this is the RhinoCommon equivalent…

TestLarry.cs (1.9 KB)

Edit: I just noticed the (i.e., not completely obstructed by other geometry in the scene) comment. Let me think about this.

1 Like