Use the Attribute class to manage Maya attributes
masterThe Attribute class in pymel.core.general provides a unified interface for all attribute-related operations, replacing the various MEL commands. Method names follow a simplified pattern based on standard Maya commands:
setAttrbecomesAttribute.setgetAttrbecomesAttribute.getconnectAttrbecomesAttribute.connect
Example usage on a camera node:
from pymel.core import *
import pymel.core.general as general
cam = general.PyNode('persp')
if cam.visibility.isKeyable() and not cam.visibility.isLocked():
cam.visibility.set(True)
cam.visibility.lock()
print cam.v.type() # shortnames also workfrom pymel.core import *
cam = general.PyNode('persp')
if cam.visibility.isKeyable() and not cam.visibility.isLocked():
cam.visibility.set(True)
cam.visibility.lock()