[cgkit-commits] maya/maya_wrapper/maya .cvsignore,NONE,1.1 __init__.py,NONE,1.1 node.py,NONE,1.1
Brought to you by:
mbaas
From: Matthias B. <mb...@us...> - 2005-09-23 09:48:58
|
Update of /cvsroot/cgkit/maya/maya_wrapper/maya In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31320/maya Added Files: .cvsignore __init__.py node.py Log Message: Maya SDK wrapper --- NEW FILE: .cvsignore --- *.pyc boost_python.dll _maya.pyd --- NEW FILE: node.py --- ###################################################################### # Maya node ###################################################################### from maya import executeCommand import types # Node class Node(object): """Wrapper around a Maya node. This wrapper allows accessing arbitrary node attributes. Special attributes: - parent """ def __init__(self, node): """Constructor. node is the node name of a Maya node. """ object.__init__(self) self._node = node def getItem(self, attrname, index): v = executeCommand("getAttr %s.%s[%d]"%(self._node, attrname, index)) return v def __getattr__(self, name): if name=="parent": v = executeCommand("listRelatives -p %s"%self._node) if v!=None: v = v[0] else: v = executeCommand("getAttr %s.%s"%(self._node, name)) return v def __setattr__(self, name, value): if name[0]=="_": object.__setattr__(self, name, value) else: val = self.val2str(value) executeCommand("setAttr %s.%s %s"%(self._node, name, val), undoEnabled=True) # val2str def val2str(self, val): """Convert a value into an argument string for a MEL command. """ # Is it already a string? if isinstance(val, types.StringTypes): return '"%s"'%val # Bool? if type(val)==bool: if val: return "1" else: return "0" # Is val a sequence? try: len(val) lst = map(lambda v: self.val2str(v), list(val)) return " ".join(lst) except: # ...it's not a sequence return repr(val) --- NEW FILE: __init__.py --- # Init from _maya import * from node import Node |