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

    Join Date
    Nov 2013
    Posts
    3
    Rep Power
    0

    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

    sel=cmds.ls(sl=True)
    print sel
    bbox = cmds.exactWorldBoundingBox(sel)
    print bbox
    cmds.polyCube()
  2. #2
  3. Contributing User
    Devshed Demi-God (4500 - 4999 posts)

    Join Date
    Aug 2011
    Posts
    4,696
    Rep Power
    480
    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
    Code:
    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