this is my code
import maya.cmds as cmds
Difference = cmds.ls ( sl = True, tl = 1)
BoundingBox = cmds.xform ( Difference, q = True, bb = True );
cmds.polyBoolOp ( op = 2, n = 'Difference' );
BoundingBoxLocation = cmds.xform ( Difference, wd = True, q = True, t = True );
BoundingBoxWidth = BoundingBox[3] - BoundingBox[0]
BoundingBoxHeight = BoundingBox[4] - BoundingBox[1]
BoundingBoxDepth = BoundingBox[5] - BoundingBox[2]
LiveBox = cmds.polyCube ( w = BoundingBoxWidth, h = BoundingBoxHeight, d = BoundingBoxDepth );
cmds.move ( BoundingBoxLocation[0], BoundingBoxLocation[1], BoundingBoxLocation[2], LiveBox, absolute = True );
cmds.displaySurface ( x = True )
Everything works except the xray