def tmp_module_information(self, *args): selected_node = pm.ls(sl=True) # only if selection is one or zero because we may need to shift select if len(selected_node) <= 1: self.moduleInstance = None mod_moduleType = None mod_namespace = None # only if selection is one if len(selected_node) == 1: selected_node = selected_node[0] # need to figure out which module type we have selected if selected_node.hasAttr("MetaNode"): mod_moduleType = utils.getModuleMetaInfo(selected_node, "ModuleType") mod_namespace = utils.getModuleMetaInfo(selected_node, "Namespace") else: _logger.warning('ModifySelected: {} does not have attribute "MetaNode"'.format(selected_node)) control_enabled = False # import the module if mod_moduleType != None: control_enabled = True # putting an instance of the module in memory module = __import__(environ.BlueprintModulePath + mod_moduleType, {}, {}, [mod_moduleType]) reload(module) moduleClass = getattr(module, module.CLASS_NAME) self.moduleInstance = moduleClass(mod_namespace, self.find_parentModule()) mod_info = self.moduleInstance.getJointInformation() for x in mod_info: print x
def build_rig(self, *args): """ Builds the skeleton """ pm.namespace(setNamespace=":") self.deleteScriptJob() # temporary way of finding all modules all_modules = pm.ls(type="network") module_instances = [] for mod in all_modules: mod_moduleType = utils.getModuleMetaInfo(mod, "ModuleType") mod_namespace = utils.getModuleMetaInfo(mod, "Namespace") module = __import__(environ.BlueprintModulePath + mod_moduleType, {}, {}, [mod_moduleType]) reload(module) moduleClass = getattr(module, module.CLASS_NAME) module_instance = moduleClass(mod_namespace, self.find_parentModule()) module_information = module_instance.getJointInformation() # module_instances.append( module_information ) module_instances.append((module_instance, module_information)) for module in module_instances: module[0].lock_joints1(module[1]) for module in module_instances: module[0].lock_joints2(module[1][5])
def delete_module(self, node): """deletes Module """ node = pm.PyNode(node) if node.hasAttr("MetaNode"): module_container = utils.getModuleMetaInfo(node, "ModuleContainer") else: return pm.lockNode(module_container, lock = False) module_namespace = utils.getModuleMetaInfo(node, "Namespace") pm.delete(module_container) pm.namespace(setNamespace = ":") pm.namespace(removeNamespace = module_namespace)
def modifySelected(self, *args): """script job will fire regardless of what is selected, so need to set up conditions so it doesn't error out""" # figure out if selected is a blueprint module selected_node = pm.ls(sl=True) # only if selection is one or zero because we may need to shift select if len(selected_node) <= 1: self.moduleInstance = None mod_moduleType = None mod_namespace = None # only if selection is one if len(selected_node) == 1: selected_node = selected_node[0] # need to figure out which module type we have selected if selected_node.hasAttr("MetaNode"): mod_moduleType = utils.getModuleMetaInfo(selected_node, "ModuleType") mod_namespace = utils.getModuleMetaInfo(selected_node, "Namespace") else: _logger.warning('ModifySelected: {} does not have attribute "MetaNode"'.format(selected_node)) control_enabled = False # import the module if mod_moduleType != None: control_enabled = True # putting an instance of the module in memory module = __import__(environ.BlueprintModulePath + mod_moduleType, {}, {}, [mod_moduleType]) reload(module) moduleClass = getattr(module, module.CLASS_NAME) self.moduleInstance = moduleClass(mod_namespace, self.find_parentModule()) _logger.info("\nModule Instance: {}".format(self.moduleInstance)) pm.textFieldGrp( self.UIwidgets["moduleOptions_name_textField"], edit=True, text=mod_namespace, enable=control_enabled ) pm.button(self.UIwidgets["moduleOptions_parent_button"], edit=True, enable=control_enabled) pm.button(self.UIwidgets["moduleOptions_delete_button"], edit=True, enable=control_enabled) pm.button(self.UIwidgets["moduleOptions_mirror_button"], edit=True, enable=control_enabled) self.createScriptJob()
def getJointInformation(self): """Given a list of joints, gather and return all the required information from this modules control objects""" # joint_positions = List of joint positions from down the hierarchy "<class 'pymel.core.nodetypes.Joint'>" # joint_orientations = A list of orientations, or axis information (orientJoint and secondaryAxisOrient for joint command). # Padded in the following tuple: (orientations, None) or (None, axisInfo) or spine. # joint.rotate.get() = "<class 'pymel.core.datatypes.Vector'>" joint.getRotation() = "<class 'pymel.core.datatypes.EulerRotation'>" # joint_rotation_order = A list of jointRotation orders (integer values gather with getAttr) "<class 'pymel.util.enum.EnumValue'>" # joint_preferredAngles = A list of joint preferred angles, optional (can pass None) "<type 'list'>" # hook_object = self.findHookObjectForLock() <type 'list'> # root_transform = Either True or False. True = R, T, and S on root joint. False = R only. "<type 'NoneType'>" # # module_information = ([joint, joint_positions, joint_orientations, joint_rotation_order, joint_preferredAngles, hook_object, root_transform]) joint_positions = [] joint_orientations = [] joint_rotation_order = [] module_joints = utils.getModuleMetaInfo(self.module_container, "ModuleJoints") for joint in module_joints: joint_positions.append(joint.getTranslation(space = "world")) joint_orientations.append(joint.getOrientation()) joint_rotation_order.append(joint.getRotationOrder()) joint_preferredAngles = None #joint.getPreferedAngle() parent_object = utils.getModuleMetaInfo(self.module_container, "ParentObject") root_transform = None module_information = (module_joints, joint_positions, joint_orientations, joint_rotation_order, joint_preferredAngles, parent_object, root_transform ) return module_information