Advertisement
Guest User

Untitled

a guest
Jun 25th, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. import maya.cmds as mc
  2.  
  3. class NodeFn( object ):
  4. def __init__(self, node):
  5. if not self.exists:
  6. mc.error('{0} - does not exist'.format(node))
  7.  
  8. @property
  9. def exists(self):
  10. return mc.objExists(node)
  11.  
  12. @property
  13. def objType(self):
  14. if not self.exists:
  15. return None
  16.  
  17. return mc.nodeType(node)
  18.  
  19. ####################
  20.  
  21. class AtrributeFn( NodeFn, object ):
  22. def __init__(self, node):
  23. super().__init__(node)
  24.  
  25. @property
  26. def parent(self):
  27. return node.split('.')[0]
  28.  
  29. @property
  30. def attr(self):
  31. return node.split('.')[1]
  32.  
  33. @property
  34. def defaultValue(self):
  35. return mc.attributeQuery(self.attr, n=self.parent, ld=1)
  36.  
  37. @defaultValue.setter
  38. def defaultValue(self, value):
  39. mc.addAttr(self, e=1, dv=value)
  40.  
  41.  
  42.  
  43. node = 'locator1.tx'
  44. x = AtrributeFn(node)
  45.  
  46. print(x.defaultValue)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement