
You could also create your attribute in the list comprehension, but if you try and run the script on a shape node that has no attributes, then the script will fail.However, if you were explicitly setting an attribute it would be as simple as yourObject.tx.set(0).I’m iterating over two lists with my list comprehension so I need to combine it again, casting it as a pm.Attribute( object name + attribute ).I then take those two combined elements to gather all the transform attributes for all of my objects.This acts like a nested iterator which will add each of (1,2,3) with each of (4,5,6) resulting in 9 combinations.But you can also loop over two lists at once with one line:.List Comprehension lets you build up lists quickly by using.You can also use makeIdentity() to quickly reset an object, but if some of your attributes are locked, this won’t work.Every iteration has a try/except on it, so that if your attribute is driven or locked the script will continue without failing.The pm.Callback() takes an argument, so instead of pm.selected() you could pass it a list of all your character rig controls, or all the locators in your scene, etc. etc.Some studios do not use PyMEL, so be aware of this. I personally use PyMEL instead of maya.cmds because it can generate a list of object pointers rather than strings, so it is a lot easier to use from an OOP point of view.Don’t forget to set the hotkey to Python. Set it to Ctrl-Shift-R in your Maya hotkey editor.


selected () ) runthescipt () Notes about this script:

set ( 1 ) except : pass runthescipt = pm. set ( 0 ) except : pass for attr in : try : pm. Import re as pm def reset_selected ( oColl ): trList = sList = # o is each object, x is each attribute for attr in : try : pm.
