SelectedGroupObject problem

Hello everyone, how can we get the selected group objects in RhinoCommon? Is there an API provided for this?
My current method is to iterate through each group in doc.Groups, and then check whether the objects in this group are selected. This method is too slow. Is there a better way?
I want to export groups as DWG file,one by one.

The normal selected objects API followed by the get selected subobjects call seems to work for me.

Example: the Rhino6 logo model file. If I select the large part of the logo after opening it, I get a group of 5 breps.

(not posting the file since it was behind one of the ‘enter your email to download’ type prompts on the McNeel site).

What’s your context? Do you have a selected group being passed into a script or plugin? Has the user selected something and then run a command or clicked a button on a plugin you wrote? Are you running a script to find top level groups and then act on them?

My idea is to select multiple groups, and then export these objects in batches as DWG format files according to the group names.