I'm trying to get the size of any object using the bounding box
def getSizes(self):
objSize = cmds.ls(sl = True)
#get the bounding box of x,y,z
sizeMinX = cmds.getAttr(objSize[0] + '.boundingBoxMinX')
sizeMaxX = cmds.getAttr(objSize[0] + '.boundingBoxMaxX')
sizeMinY = cmds.getAttr(objSize[0] + '.boundingBoxMinY')
sizeMaxY = cmds.getAttr(objSize[0] + '.boundingBoxMaxY')
sizeMinZ = cmds.getAttr(objSize[0] + '.boundingBoxMinZ')
sizeMaxZ = cmds.getAttr(objSize[0] + '.boundingBoxMaxZ')
#get the sizes
if (sizeMinX < 0 and sizeMaxX > 0) or (sizeMaxX < 0 and sizeMinX > 0):
sizeX = abs(sizeMinX) + abs(sizeMaxX)
else:
sizeX = abs(sizeMaxX) - abs(sizeMinX)
if (sizeMinY < 0 and sizeMaxY > 0) or (sizeMaxY < 0 and sizeMinY > 0):
sizeY = abs(sizeMinY) + abs(sizeMaxY)
else:
sizeY = abs(sizeMaxY) - abs(sizeMinY)
if (sizeMinZ < 0 and sizeMaxZ > 0) or (sizeMaxZ < 0 and sizeMinZ > 0):
sizeZ = abs(sizeMinZ) + abs(sizeMaxZ)
else:
sizeZ = abs(sizeMaxZ) - abs(sizeMinZ)
This works fine when the object is perpendicular to the x,y, or z axis
however when i rotate the object it gives me different sizes. for example
if i have a cube(10,10,10) it will return these values normally but when i
rotate the object it will give me different values.
Is there a way to get the bounding box of the object not in world space?
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/3cab85d2-1c4e-4ae5-9ca6-15be3f3307a5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.