# ------------------------------------------------------------------------------------ # gbDeleteConnection.py - Maya Python Script # ------------------------------------------------------------------------------------ # # DESCRIPTION: # This script takes your selection and deletes the attribute connections. # It cleans translation, rotation, scale and visibility. # # USAGE: # (PYTHON) import gbDeleteConnection; gbDeleteConnection.deleteConnection() # (MEL) python("import gbDeleteConnection;gbDeleteConnection.deleteConnection()") # # AUTHOR: # Giorgio Bertolone - mail@giorgiobertolone.com - www.giorgiobertolone.com # Copyright (C)2010- Giorgio Bertolone - All Rights Reserved. # # VERSIONS: # 1.00 - Dec 28, 2010 - Initial Release # # ------------------------------------------------------------------------------------ import maya.cmds as mc def deleteConnection(): # check and warn if nothing is selected sel = mc.ls( sl=True, fl=True ) if sel == []: mc.confirmDialog( title="Selection Error", message="Nothing is selected.", button=["Ok"], defaultButton="Ok" ) # for each selection clean the translation, rotation, scale and visibility attributes for i in sel: unPlug( '%s.tx' % i ) unPlug( '%s.ty' % i ) unPlug( '%s.tz' % i ) unPlug( '%s.rx' % i ) unPlug( '%s.ry' % i ) unPlug( '%s.rz' % i ) unPlug( '%s.sx' % i ) unPlug( '%s.sy' % i ) unPlug( '%s.sz' % i ) unPlug( '%s.visibility' % i ) def unPlug(plug): # if the plug is the destination of a connection if mc.connectionInfo(plug, isDestination=True): # plug is exact destination plug = mc.connectionInfo(plug, getExactDestination=True) # if it's read only get the source of the connection and use disconnectAttr readOnly = mc.ls(plug, ro=True) if readOnly: source = mc.connectionInfo(plug, sourceFromDestination=True) mc.disconnectAttr(source, plug) # otherwise just use delete else: mc.delete(plug, icn=True)