You need to get dagpath from your selection first, then extend it to
the shape. And put the dagpath to MFnDagNode to get bbox infomation.

import maya.OpenMaya as OpenMaya

selectList = OpenMaya.MSelectionList()
OpenMaya.MGlobal.getActiveSelectionList( selectList )
dagpath = OpenMaya.MDagPath()

selectList.getDagPath(0, dagpath)
dagpath.extendToShape()
fDagNode = OpenMaya.MFnDagNode(dagpath)

bbox = fDagNode.boundingBox()
print bbox.width()
print bbox.height()

Thanks,
Makoto

On 11月14日, 午前1:38, johnvdz <john.vanderz...@gmail.com> wrote:
> Hi all,
>
> i'm trying to get the Bounding box of a prexisting mesh. but i'm not
> sure if i'm aproching it the right way. has anyone dont this before? i
> see some samples of setting a BBox but none for setting.
>
> i'm new to api so i could be doing the wrong thing here eaither way it
> doesnt work. any help would be great. i need to call this so i can plug
> height, width, depth into another function.
>
> cheers
>
> john
> ################
>
> import maya.OpenMaya as OpenMaya
>
> def boundingBox():
>
>         selection = OpenMaya.MSelectionList()
>         OpenMaya.MGlobal.getActiveSelectionList( selection )
>
>         dagPath = OpenMaya.MDagPath()
>         mObj = OpenMaya.MObject()
>         Bbox=OpenMaya.MBoundingBox(mObj)
>         print Bbox.width()
>         print Bbox.height()
>
> boundingBox()
> #####################  

--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/python_inside_maya
-~----------~----~----~----~------~----~------~--~---

Reply via email to