Website powered by

Smart Null-Attribute Script

General / 30 January 2017

Here’s a quick script that I wrote during my last rigging project. For every object in the selection, it gets the keyable attributes and their defaults and sets those attributes to their defaults.

It works on default and user-defined attributes. I have it mapped to a hotkey (ctrl+0) and it really speeds things up!

 

 import maya.cmds as cmds   # bm_nullAttr # sets channel box values to default for every object in selection. Works on default and custom attributes.  # get the selection def nullAttr():     sel = cmds.ls(sl=1)     for obj in sel:         # list the keyable attributes on that object         keyable = cmds.listAttr(obj, k=1)         for attr in keyable:             # find each attribute's default value and set it             default = cmds.attributeQuery(attr, node=obj, listDefault=1)             cmds.setAttr(obj + "." + attr, default[0])