I am trying to create a Python script to generate cubes in Maya which represent the object space bounding boxes of objects.
For example, if I create random objects (sphere, cube, pyramid, cone, etc.) in Maya, I want to replace those selected objects with a cube which has the dimensions of that object's bounding box.
So if I create 3 different objects, (for instance a cone, a sphere, and a pyramid), there should be three individual cubes that are the bounding boxes of those objects.
Here is the script that I tried to build, but I am stuck right after this.
Steps that I followed:
create a sphere. (Manually by clicking the 'generate sphere button' on Maya program)
after step 1, run the script I built
import maya.cmds as cmds
sel = cmds.ls(sl=True)
print sel
bbox = cmds.exactWorldBoundingBox(sel)
print bbox
cmds.polyCube()