# -*- coding: utf-8 -*- """ :author: Jeremy Ernst :description: This module contains the spine component class for constructing a spine with 3 to 5 joints. """ import artv2.components.chain as chain import artv2.utilities.general_utilities as utils import artv2.utilities.error_utilities as errors import pymel.core as pm # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # class Spine(chain.Chain): """ This class creates a pine component for creating a spine with a pelvis and 3 to 5 spine joints. """ nice_name = "Spine" category = "Limbs" base_name = "spine" has_sides = False can_overwrite_names = True joint_mover_file = "resources\\rigging_guides\\spine.ma" # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # def _add_metadata(self, network_node, prefix, suffix): super(Spine, self)._add_metadata(network_node, prefix, suffix) network_node.unlock() network_node.num_joints.set(lock=False) pm.addAttr("{0}.num_joints".format(network_node), edit=True, min=3, max=5, dv=True) network_node.num_joints.set(lock=True) network_node.lock() # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # @property def num_joints(self): """ Property for defining/returning the number of spine joints example usage: .. code-block:: python spine_inst = spine.Spine() spine_inst.num_joints = 5 :return: (int) number of spine joints. """ return self.network_node.num_joints.get() @num_joints.setter def num_joints(self, new_number): if utils.validate_integer(new_number, 3, 5): if new_number != self.num_joints: new_number = int(new_number) self.logger.info("{0}.num_joints: Setting property to {1}".format(self.__class__.__name__, new_number)) # change number of joints aim_mode = self.network_node.isAiming.get() loc, dependencies = self._change_number_of_joints("spine_01", aim_mode, new_number) # redo markups self._redo_markups("spine", "spine_01", "pelvis") utils.set_attribute(self.network_node, "num_joints", new_number) # cleanup self._toggle_data_cleanup("spine_01", aim_mode, loc) # report if dependencies: errors.report_issues(dependencies) else: self.logger.warning("{0}.num_joints: {1} is not a valid value.".format(self.__class__.__name__, new_number)) errors.raise_error("{0} is not a valid value!".format(new_number))