def _eye_helpers(self, armature_object, settings): from mpfb.services.righelpers.eyehelpers.eyehelpers import EyeHelpers helpers = EyeHelpers.get_instance(settings) helpers.apply_ik(armature_object) RigHelpersProperties.set_value("eye_mode", "IK", entity_reference=armature_object)
def execute(self, context): _LOG.enter() armature_object = context.object from mpfb.ui.righelpers.righelperspanel import SETUP_HELPERS_PROPERTIES # pylint: disable=C0415 settings = SETUP_HELPERS_PROPERTIES.as_dict(entity_reference=context.scene) finger_mode = RigHelpersProperties.get_value("finger_mode", entity_reference=armature_object) leg_mode = RigHelpersProperties.get_value("leg_mode", entity_reference=armature_object) arm_mode = RigHelpersProperties.get_value("arm_mode", entity_reference=armature_object) eye_mode = RigHelpersProperties.get_value("eye_mode", entity_reference=armature_object) if finger_mode: self._finger_helpers(armature_object, settings) if leg_mode: self._leg_helpers(armature_object, settings) if arm_mode: self._arm_helpers(armature_object, settings) if eye_mode: self._eye_helpers(armature_object, settings) self.report({'INFO'}, "Helpers were removed") return {'FINISHED'}
def _finger_helpers(self, armature_object, settings): from mpfb.services.righelpers.fingerhelpers.fingerhelpers import FingerHelpers for side in ["left", "right"]: helpers = FingerHelpers.get_instance(side, settings) helpers.apply_ik(armature_object) RigHelpersProperties.set_value("finger_mode", settings["finger_helpers_type"], entity_reference=armature_object)
def poll(cls, context): _LOG.enter() if context.object is None or context.object.type != 'ARMATURE': return False armature_object = context.object finger_mode = RigHelpersProperties.get_value("finger_mode", entity_reference=armature_object) leg_mode = RigHelpersProperties.get_value("leg_mode", entity_reference=armature_object) arm_mode = RigHelpersProperties.get_value("arm_mode", entity_reference=armature_object) eye_mode = RigHelpersProperties.get_value("eye_mode", entity_reference=armature_object) return finger_mode or leg_mode or arm_mode or eye_mode
def draw(self, context): _LOG.enter() layout = self.layout scene = context.scene if context.object is None or context.object.type != 'ARMATURE': return armature_object = context.object finger_mode = RigHelpersProperties.get_value("finger_mode", entity_reference=armature_object) leg_mode = RigHelpersProperties.get_value("leg_mode", entity_reference=armature_object) arm_mode = RigHelpersProperties.get_value("arm_mode", entity_reference=armature_object) eye_mode = RigHelpersProperties.get_value("eye_mode", entity_reference=armature_object) if finger_mode or leg_mode or arm_mode or eye_mode: self._remove_helpers(scene, layout) else: self._arm_helpers(scene, layout) self._leg_helpers(scene, layout) self._finger_helpers(scene, layout) self._eye_helpers(scene, layout) self._apply_helpers(scene, layout)
def remove_ik(self, armature_object): """Remove rig helpers for arms and hands based on the settings that were provided when constructing the class, and information about the current status of the armature object.""" _LOG.enter() self._bone_info = RigService.get_bone_orientation_info_as_dict(armature_object) mode = str(RigHelpersProperties.get_value("arm_mode", entity_reference=armature_object)).strip() _LOG.debug("mode is", mode) include_shoulder = False if mode == "LOWERUPPERSHOULDER": include_shoulder = True if mode == "SHOULDERCHAIN": include_shoulder = True bpy.ops.object.mode_set(mode='POSE', toggle=False) bones_to_clear = self.get_reverse_list_of_bones_in_arm(True, True, True, include_shoulder) for bone_name in bones_to_clear: _LOG.debug("Will attempt to clear constraints from", bone_name) RigService.remove_all_constraints_from_pose_bone(bone_name, armature_object) self._show_bones(armature_object, bones_to_clear) bpy.ops.object.mode_set(mode='EDIT', toggle=False) ik_bones = [ self.which_arm + "_hand_ik", self.which_arm + "_elbow_ik", self.which_arm + "_shoulder_ik" ] for bone_name in ik_bones: bone = RigService.find_edit_bone_by_name(bone_name, armature_object) if bone: armature_object.data.edit_bones.remove(bone) bpy.ops.object.mode_set(mode='OBJECT', toggle=False) _LOG.debug("Done")
def remove_ik(self, armature_object): """Remove rig helpers for hips, legs and feet based on the settings that were provided when constructing the class, and information about the current status of the armature object.""" _LOG.enter() mode = str( RigHelpersProperties.get_value( "leg_mode", entity_reference=armature_object)).strip() _LOG.debug("mode is", mode) include_hip = mode == "LOWERUPPERHIP" bpy.ops.object.mode_set(mode='POSE', toggle=False) bones_to_clear = self.get_reverse_list_of_bones_in_leg( True, True, True, include_hip) for bone_name in bones_to_clear: _LOG.debug("Will attempt to clear constraints from", bone_name) RigService.remove_all_constraints_from_pose_bone( bone_name, armature_object) self._show_bones(armature_object, bones_to_clear) bpy.ops.object.mode_set(mode='EDIT', toggle=False) ik_bones = [ self.which_leg + "_foot_ik", self.which_leg + "_knee_ik", self.which_leg + "_hip_ik" ] for bone_name in ik_bones: bone = RigService.find_edit_bone_by_name(bone_name, armature_object) if bone: armature_object.data.edit_bones.remove(bone) bpy.ops.object.mode_set(mode='OBJECT', toggle=False) _LOG.debug("Done")
def remove_ik(self, armature_object): """Remove rig helpers for fingers based on the settings that were provided when constructing the class, and information about the current status of the armature object.""" _LOG.enter() self._bone_info = RigService.get_bone_orientation_info_as_dict(armature_object) mode = str(RigHelpersProperties.get_value("finger_mode", entity_reference=armature_object)).strip() _LOG.debug("mode is", mode) if mode in ["GRIP", "MASTER", "GRIP_AND_MASTER"]: self._clear_all_finger_constraints(armature_object) self._remove_grip(armature_object) if mode in ["MASTER", "GRIP_AND_MASTER"]: self._clear_master_grip(armature_object) if mode == "POINT": self._clear_all_finger_constraints(armature_object) self._remove_point(armature_object) _LOG.debug("Done") bpy.ops.object.mode_set(mode='POSE', toggle=False)
def _leg_helpers(self, armature_object, settings): from mpfb.services.righelpers.leghelpers.leghelpers import LegHelpers for side in ["left", "right"]: helpers = LegHelpers.get_instance(side, settings) helpers.remove_ik(armature_object) RigHelpersProperties.set_value("leg_mode", "", entity_reference=armature_object)