Boolean modifier on groups - can't select 2nd object - is this possible?
When I run your Script in a fresh Blender pasted in a Text Editor, I get a couple of Icospheres and a cube. Now I select all the Icospheres and Join all of them (CtrlJ). This joined object now works pretty well (after being hidden) with your Cube and a Boolean Modifier set to Intersect with this object:



You don't need any groups. So did I understand your question properly?

If you want to retain only that pieces separately you could Apply the Modifier and then in Edit Mode Separate (P) by loose parts.