Selecting all instance references

Is there a way in RhinoCommon (c#) to select all blocks in a model without requesting the user to select?

I haven’t tested this. But I should work…

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
  var rc = Result.Cancel;

  var idef_name = doc.Layers.CurrentLayer.Name;
  rc = RhinoGet.GetString("Name of block to select", false, ref idef_name);
  if (rc != Result.Success)
    return rc;

  var idef = doc.InstanceDefinitions.Find(idef_name, true);
  if (null == idef)
    return Result.Nothing;

  var irefs = idef.GetReferences(0);
  if (null == irefs)
    return Result.Nothing;

  foreach (var iref in irefs)


  return Result.Success;