Disable SubObjects Selection in CustomRhinoObject

Hi all, I’m currently trying to create a terrain by inheriting from CustomMeshObject and I want the user to only be able to select the whole terrain and not its sub-objects (e.g. MeshEdge, MeshPoint etc) when selecting the terrain from the viewport. My current approach is to override the OnPicked() method and modify its implementation with the following code.

 protected override void OnPicked(PickContext context, IEnumerable<ObjRef> pickedItems)
  {
      base.OnPicked(context, pickedItems);
      foreach(ObjRef objref in pickedItems)
      {
          Rhino.RhinoDoc.ActiveDoc.Objects.Select(objref.ObjectId);
      }
      Rhino.RhinoDoc.ActiveDoc.Views.Redraw();
  }

Obviously this is not a good way to do this, as it requires frequent and extensive viewport refreshes, so is there a better and more efficient way to achieve this?

Just override CustomRhinoObject’s method OnPick(), the code is as follow:

  protected override IEnumerable<ObjRef> OnPick(PickContext context)
  {
      IEnumerable<ObjRef> objs = base.OnPick(context);
      if(objs == null)
      {
          return null;
      }
      else
      {
          if (objs.Count() == 1 && objs.ElementAt(0).GeometryComponentIndex.Index == -1)
          {
              return new List<ObjRef>() {new ObjRef(this.Id)};
          }
          return null;
      }
  }

This works