Hello,How can select these Cubes in groups use python



like the picture,i try cmds.select(“group2”, hierarchy=True),all things in group2 selected…but the “group” cannt bake animation.i want bake cubes animation and export to FBX


Maybe I don’t understand the question, but if you do this it at least lists both the group nodes and the cube nodes:

import maya.cmds as cmds

main_selection = cmds.ls(sl=True)
selection = cmds.select(hierarchy = True)
new_selection = cmds.ls(sl = True)
print (new_selection)