def import_metaClasses(): metadata_path = os.path.join(os.path.dirname(__file__), "metadata") global metaClasses metaClasses = {} print "\n" for (dirpath, dirnames, filenames) in os.walk(metadata_path): files = [f for f in filenames if not f.startswith("_") and f.endswith(".py")] for filename in files: filepath = os.path.join(dirpath, filename) file_mod = filename.split(".py")[0] toolpath = dirpath.split(metadata_path)[-1] tool_mods = ["tool", "autoRig", "metadata"] tool_mods.extend(toolpath.split(os.sep)[1::]) tool_mods.append(file_mod) mod = __import__(".".join(tool_mods), (), (), [file_mod]) reload(mod) classes = [x for x in dir(mod) if isclass(getattr(mod, x))] for c in classes: print "Register Metadata Class .. %s .. %s" % (c, filepath) classInstance = getattr(mod, c) virtualClasses.register(classInstance, nameRequired=False) metaClasses[c] = classInstance return metaClasses
def register_metaClasses(): metadata_path = os.path.join(config["PIXO_RIGGING_PATHS"][TOOL_PATH], 'autoRig', 'metadata') global AUTORIG_METACLASSES AUTORIG_METACLASSES = {} print '\n' for (dirpath, dirnames, filenames) in os.walk(metadata_path): files = [f for f in filenames if not f.startswith("_") and f.endswith('.py')] for filename in files: filepath = os.path.join(dirpath, filename) file_mod = filename.split('.py')[0] toolpath = dirpath.split(metadata_path)[-1] tool_mods = ['tool', 'autoRig', 'metadata'] tool_mods.extend(toolpath.split(os.sep)[1::]) tool_mods.append(file_mod) mod = __import__ ('.'.join(tool_mods), (), (), [file_mod]) ; reload(mod) classes = [x for x in dir(mod) if isclass(getattr(mod, x))] for c in classes: print "Register Metadata Class .. %s .. %s" %(c, filepath) classInstance = getattr(mod, c) virtualClasses.register( classInstance, nameRequired=False ) AUTORIG_METACLASSES[c] = classInstance
if rotate is not None: newNode.attr('rotate').set(rotate) class LegJoint(CustomJointBase): _jointClassID = 'joint_leg' def kick(self): print "%s is kicking" % self.name() class JawJoint(CustomJointBase): _jointClassID = 'joint_jaw' def munch(self): print "%s is munching" % self.name() # we don't need to register CustomJointBase because it's just an abstract class to help us easily make our other virtual nodes virtualClasses.register( LegJoint, nameRequired=False ) virtualClasses.register( JawJoint, nameRequired=False ) def testJoint(): # make some regular joints Joint() Joint() # now make some of our custom joints LegJoint(name='leftLeg') JawJoint(rotate=(90,45,0)) # now list the joints and see which ones are our special joints res = ls(type='joint') for x in res: if isinstance(x, LegJoint ): x.kick()
def kick(self): print("%s is kicking" % self.name()) return "kiyaah!" class JawJoint(CustomJointBase): _jointClassID = 'joint_jaw' def munch(self): print("%s is munching" % self.name()) return "nom nom nom..." # we don't need to register CustomJointBase because it's just an abstract class to help us easily make our other virtual nodes virtualClasses.register(LegJoint, nameRequired=False) virtualClasses.register(JawJoint, nameRequired=False) def test_Joint(): # make some regular joints pm.nt.Joint() pm.nt.Joint() # now make some of our custom joints LegJoint(name='leftLeg') JawJoint(rotate=(90, 45, 0)) # now list the joints and see which ones are our special joints res = pm.ls(type='joint') results = [] for x in res:
class LegJoint(CustomJointBase): _jointClassID = 'joint_leg' def kick(self): print "%s is kicking" % self.name() class JawJoint(CustomJointBase): _jointClassID = 'joint_jaw' def munch(self): print "%s is munching" % self.name() # we don't need to register CustomJointBase because it's just an abstract class to help us easily make our other virtual nodes virtualClasses.register(LegJoint, nameRequired=False) virtualClasses.register(JawJoint, nameRequired=False) def testJoint(): # make some regular joints pm.nt.Joint() pm.nt.Joint() # now make some of our custom joints LegJoint(name='leftLeg') JawJoint(rotate=(90, 45, 0)) # now list the joints and see which ones are our special joints res = pm.ls(type='joint') for x in res: if isinstance(x, LegJoint):
def _delete_proxy_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) proxy = self.proxy.get() proxy.message // self.proxy pm.delete(proxy) #=========================================================================== # INSTALL RIG FUNCTIONS #=========================================================================== def _create_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return def _connect_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return #=========================================================================== # UNINSTALL RIG FUNCTIONS #=========================================================================== def _disconnect_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return def _delete_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return virtualClasses.register( JointMetadata, nameRequired=False )
matrix.asMatrixInverse()) def addBuffer(self, suffix='BUF'): name = '_'.join([self.nodeName(), suffix]) buffer = pmc.group(empty=True, name=name) buffer.setMatrix(self.getTopBuffer().getMatrix(worldSpace=True), worldSpace=True) pmc.parent(buffer, self.getTopBuffer().getParent()) pmc.parent(self.getTopBuffer(), buffer) return buffer def match(self, node): self.setMatrix(node.getMatrix(worldSpace=True), worldSpace=True) virtualClasses.register(ControlCurve, nameRequired=False) ##### SHAPE PRESETS ##### class LocatorCurve(ControlCurve): _shapeID = 'LocatorCurve' _data = [{ 'knots': [0.0, 1.0], 'cvs': [dt.Point([0.0, 0.0, -25.0]), dt.Point([0.0, 0.0, 25.0])], 'degree': 1 }, { 'knots': [0.0, 1.0], 'cvs': [dt.Point([0.0, 25.0, 0.0]), dt.Point([0.0, -25.0, 0.0])],
def _delete_proxy_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) proxy = self.proxy.get() proxy.message // self.proxy pm.delete(proxy) #=========================================================================== # INSTALL RIG FUNCTIONS #=========================================================================== def _create_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return def _connect_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return #=========================================================================== # UNINSTALL RIG FUNCTIONS #=========================================================================== def _disconnect_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return def _delete_rig_node(self): logger.debug("%s - Function Called ( %s )"%(self.name(), inspect.stack()[0][3])) return virtualClasses.register( InfoMetadata, nameRequired=False )
self.addControls(controls) self.snap() for i in range(len(targets)): if i > 0: pmc.parentConstraint(targets[i], targets[i - 1], mo=True) def snap(self, time=None): time = time if time else pmc.currentTime(q=True) for control_target in self.getControlTargets(): joint_matrix = control_target.target.worldMatrix.get(time=time) control_target.control.setMatrix(joint_matrix, worldSpace=True) virtualClasses.register(FKRigNode, nameRequired=False) class Struct(object): def __init__(self, **entries): self.__dict__.update(entries) class RigComponent(object): ''' This is the base class of all RigComponents. The goal of this is mostly to group parts together rather than represent them as a whole. ''' _name = None
return isVirtual @classmethod def _preCreateVirtual(cls, **kwargs): """This is called before creation. Python allowed.""" return kwargs @classmethod def _postCreateVirtual(cls, newNode): """ This is called before creation, PyMEL/Cmds allowed.""" for attr in cls.__STRING_ATTRS: newNode.addAttr(attr, dt='string') newNode.setAttr('PyNodeType', cls.PyNodeType) def serialize(self): attrs = {} for attr in self.__STRING_ATTRS: attrs[attr] = self.getAttr(attr) return attrs # Make SutureNode available to PyMEL virtualClasses.register(SutureNode, nameRequired=False) class Rig(SutureNode): FILE_EXT = '.rig' PyNodeType = 'Rig' virtualClasses.register(Rig, nameRequired=False)