Replace objects with a group of objects using Python

I know how to add an object from another layer into main scene, but how can I do it for a group of objects:
Here’s my blend file

What I am trying to do is that as soon as the cubes collide (controls are UP/DOWN/LEFT/RIGHT), I want the original cube to be removed(which already works) and replaced with the group of objects from layer 2 (brokenCube).
The brokenCube is created using cell fracture.

To sum it up, I need to replace Object cube with group brokenCube on collision with player object

If you have the group that you want to move to another layer you can use the ‘objects’ property to get a collection of the objects in the group. Then just loop through those objects and set the layer(s) you want them visible on with each objects ‘layers’ property (boolean array of 20 items).

example:

group = bpy.data.groups[“Group”] #Your group name

for obj in group.objects:
obj.layers = (True,False,False,False,False,False,False,False,False,False,
False,False,False,False,False,False,False,False,False,False)

#This is assuming the layer you want move to is 1