1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2013
    Rep Power

    MAYA. python help needed ASAP . Replacing an object with a cube.

    Hello all, I am a maya user and I am trying to create a python script to generate cubes which represent the object space bounding boxes of objects.

    For example, if I create random objects (sphere, cube, pyramid, cone, and 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 has bounding box of a cone, a sphere, and a pyramid.

    I have to make cubes that has bounding box of the objects. just by executing the script.

    here is the script that I tried to build, but I am stuck right after this

    Steps that I followed:

    1) create a sphere. (Manually by clicking the 'generate sphere button' on Maya program)

    2) after step 1, this is the python script that I tried to build on

    import maya.cmds as cmds

    print sel
    bbox = cmds.exactWorldBoundingBox(sel)
    print bbox
  2. #2
  3. Contributing User
    Devshed God 1st Plane (5500 - 5999 posts)

    Join Date
    Aug 2011
    Rep Power
    I don't have autodesk and it doesn't sound free.

    Wouldn't the polyCube need sizes from bbox?

    (This I realize from your post. Next I learn how.)

    Can you not search the internet for a bit of help?

    Python examples
    import maya.cmds as cmds
    cmds.polyCube( sx=10, sy=15, sz=5, h=20 )
    #result is a 20 units height rectangular box
    #with 10 subdivisions along X, 15 along Y and 20 along Z.
    [code]Code tags[/code] are essential for python code and Makefiles!

IMN logo majestic logo threadwatch logo seochat tools logo