SetCustomGeometryFilter issue

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.SubObjectSelect = false;
			getPlane.GeometryFilter = ObjectType.Surface;
			getPlane.GeometryAttributeFilter = GeometryAttributeFilter.TopSurface;
			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();

PlanarSurfaceTest.3dm (721.0 KB)

Hi @LarryL,

Sometimes doing less is better. Since you’re providing your own filtering, there isn’t much reason to set too many geometry filters and geometry filter attributes.

Let me know if the attached, which should work with or without subobject selection enabled, helps.

TestLarry.cs (1.8 KB)

– Dale

Thanks Dale. That does the trick. I think in addition to too many geometry filters the other part I may have been missing is that the filter gets called once as the brep and also as the brep face for a planar brep even when subobject selection is disabled.

Thanks again for your help.