pymel notes
import pymel.core as pm
sel = pm.ls(sl=True, fl=True)
# To get string name of object from pynode:
sel.name()
# To get value of an attribute:
sel.attr('translateY').get()
# To set a value:
sel.attr('translateY').set(value)
# Loop through transform node attributes example:
for transform in 'trs': # translate, rotate, scale
for axis in 'xyz':
channel = '%s%s' %(transform, axis) # e.g. 'tx', 'rz', 'sy'
if node.attr(channel).isLocked(): continue # avoid locked attrs
attrs.append(channel)
# Get original default value of an attribute:
default_value = pm.attributeQuery('ty', node='pSphere1', ld=True)[0] #returns list
# If set attr isn't added to undo (pymel bug):
pm.setAttr(node.attr(attribute), value)
# undo chunk
pm.undoInfo(openChunk=True)
pm.undoInfo(closeChunk=True)