3D animation,rigging,coding, math ,fun stuff welcome !

turn2BoundingBox.py

"""
Copyright (C) 2009 Rick Fronek
melvin.3d@gmail.com

Python Script File:
Function List:
                        turn2BoundingBox


MODIFY THIS AT YOUR OWN RISK

Update Date:    Feb 07 2010

Description: Takes selected objects checks if the trans node has 

                       overrides diabled and then sets teh overrides on the 
                       the shapes of the selected nodes. I wrote this for 
                       visual correction if you will , of trc's that get imported 
                       from PeelSolve plugin.
Install :
                Put it into your maya script dir and then
                rehash or restart maya. Use regular import.

                from utils import turn2BoundingBox
"""

import maya.cmds as mc

def turn2BoundingBox(switch):
    selection = mc.ls(sl=True)
    if switch:
        for each in selection:
            # check if the transnode has the override on or not
            if mc.getAttr(each + ".overrideEnabled") == 1:
                mc.setAttr(each + ".overrideEnabled" , 0)
            # get the shape of the selection
            lShape = mc.listRelatives(each, shapes=True)
            mc.setAttr(lShape[0] + ".overrideEnabled" , 1)
            mc.setAttr(lShape[0] + ".overrideLevelOfDetail" , 1)
        print 'All Done - switched to custom view..'
    if not switch:
        for each in selection:
            # check if the transnode has the override on or not
            if mc.getAttr(each + ".overrideEnabled") == 1:
                mc.setAttr(each + ".overrideEnabled" , 0)
            # get the shape of the selection
            lShape = mc.listRelatives(each, shapes=True)
            mc.setAttr(lShape[0] + ".overrideEnabled" , 0)
            mc.setAttr(lShape[0] + ".overrideLevelOfDetail" , 0)
        print 'All Done - switched back to normal..'