Hi Dale/Steve,
I’m trying to create a CustomGeometryFilter delegate that just selects planar surfaces. The sample command is below. I seem to be missing something because the delegate appears to be called for all of the geometry in my model so it returns true for some things and false for others, the net result is it doesn’t return from the Get call. If I just return true all of the time in the delegate, it works fine when I select the planar srf, but of course also returns when I select other objects. I’m attaching a sample model with a planar srf to demonstrate.
What am I missing here?
using Rhino;
using Rhino.Geometry;
using Rhino.Commands;
using Rhino.Input.Custom;
using Rhino.DocObjects;
namespace examples_cs
{
public class CustomGeometryFilterCommand : Command
{
private double m_tolerance;
public override string EnglishName { get { return "csCustomGeometryFilter"; } }
protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
GetObject getPlane = new GetObject();
getPlane.SetCommandPrompt("Select planar surface.");
getPlane.DisablePreSelect();
getPlane.SubObjectSelect = false;
getPlane.GeometryFilter = ObjectType.Surface;
getPlane.GeometryAttributeFilter = GeometryAttributeFilter.TopSurface;
getPlane.SetCustomGeometryFilter(PlanarSurfaceGeometryFilter);
getPlane.Get();
if (getPlane.CommandResult() == Result.Success && getPlane.Result() == Rhino.Input.GetResult.Object)
{
Rhino.UI.Dialogs.ShowMessage("Got it", "Message");
}
return Result.Success;
}
private bool PlanarSurfaceGeometryFilter(RhinoObject rhObject, GeometryBase geometry, ComponentIndex componentIndex)
{
//return true;
return null != geometry && geometry is Brep && (geometry as Brep).IsSurface && (geometry as Brep).Surfaces[0].IsPlanar();
}
}
}