CustomGeometryFilter method not called or with wrong arguments


Hi all,

I’m trying to create a custom GetObject class that only enables selection of naked mesh edges from a given mesh. However, I experience that either the CustomGeometryFilter() method that I implemented is not being called, or that when it is called, it only passes top-level objects with ComponentIndex being of InvalidType.

To be clear: I experimented with setting different options of the custom GetObject class like SubObjectSelect, BottomObjectPreference, DeselectAllBeforePostSelect, OneByOnePostSelect and GeometryFilter. As far as I can tell, the CustomGeometryFilter() method was only being called if the GeometryFilter property is not set, and the SubObjectSelect and BottomObjectPreference were not set either.

Is there any combination of properties which will allow my method to be called, with a valid ComponentIndex argument that refers to an edge (ComponentIndexType.MeshTopologyEdge)?



(Menno Deij - van Rijswijk) #2

I can differentiate naked edges on a mesh in the code below, but I can’t seem to be able to sub select the edge after the command ends. Maybe the code is, as it is below, useful for you anyway.

public override Result RunActualCommand(RhinoDoc doc, RunMode mode)
    ObjRef mRef;

    GetObject go = new GetObject();
    go.GeometryFilter = ObjectType.MeshEdge;

    while (true)
        GetResult gr = go.Get();
        if (gr == GetResult.Cancel)
            return Result.Cancel;
        if (gr == GetResult.Object)
            mRef = go.Object(0);
            RhinoObject obj = mRef.Object();

            ComponentIndex ci = mRef.GeometryComponentIndex;
            if (ci.ComponentIndexType == ComponentIndexType.MeshTopologyEdge)
                Mesh m = mRef.Mesh();
                int[] facesOnEdge = m.TopologyEdges.GetConnectedFaces(ci.Index);
                bool naked = null == facesOnEdge || facesOnEdge.Length <= 1;
                if (naked)
                    if (obj.IsSubObjectSelectable(ci, true))
                        int i = obj.SelectSubObject(ci, true, true); // this does not work


    return Result.Success;


Thanks Menno for your workaround. I am aware that there are lots of ways to achieve the same endresult (obtaining a naked mesh edge), but I was really looking for a way that other edges were simply not selectable (since it is very easy to click a wrong edge). However, so far this does not seem possible to me.

(Dale Fugier) #4

Mesh subobject picking did not call CustomGeometryFilter at all. This will be fixed in the next Rhino WIP.


Hi Dale,

is this really not something that can be fixed in a service release for Rhino 5? We are working with meshes a lot, and not having this is really a bummer…


(Dale Fugier) #6

Hi Mathias,

I believe if this were a simple fix, it would have been merged into V5…

– Dale


Hi @dale I run into this problem today. Is it already fixed in the wip? (i cannot check the issue at jetbrains because i have no permissions).

Exists another path to accomplish this? I was checking the SelCommands but I don’t know how they work.


(Menno Deij - van Rijswijk) #8

The issue was resolved two years ago, and has the following helpful code attached as example how to create a custom edge picker:

class CRhinoGetNakedMeshEdges : public CRhinoGetObject

  bool CustomGeometryFilter(const CRhinoObject* obj, const ON_Geometry* geom, ON_COMPONENT_INDEX ci) const
    bool rc = false;
    if (ci.m_type == ON_COMPONENT_INDEX::meshtop_edge)
      const ON_MeshComponentRef* ref = ON_MeshComponentRef::Cast(geom);
      if (0 != ref)
        const ON_MeshTopologyEdge* top_edge = 0;
        if (0 != top_edge && 1 == top_edge->m_topf_count)
          return true;
    return rc;


Thank you :slight_smile: