def convert_to_rigify(self, armature_object): _LOG.enter() self._setup_spine(armature_object) self._setup_arms(armature_object) self._setup_legs(armature_object) self._setup_shoulders(armature_object) self._setup_head(armature_object) self._setup_fingers(armature_object) bpy.ops.object.mode_set(mode='OBJECT', toggle=False) armature_object.data.rigify_rig_basename = armature_object.name + ".rigify" if self.produce: bpy.ops.pose.rigify_generate() rigify_object = bpy.context.active_object rigify_object.show_in_front = True child_meshes = ObjectService.get_list_of_children(armature_object) for child_mesh in child_meshes: self._adjust_mesh_for_rigify(child_mesh, rigify_object) if not self.keep_meta: bpy.data.objects.remove(armature_object, do_unlink=True)
def execute(self, context): scene = context.scene if not ObjectService.object_is_skeleton(context.active_object): self.report({'ERROR'}, "Must have armature object selected") return {'FINISHED'} from mpfb.ui.addrig.addrigpanel import ADD_RIG_PROPERTIES # pylint: disable=C0415 armature_object = context.active_object delete_after_generate = ADD_RIG_PROPERTIES.get_value( "delete_after_generate", entity_reference=scene) bpy.ops.pose.rigify_generate() rigify_object = context.active_object rigify_object.show_in_front = True _LOG.debug("rigify", rigify_object) for child in ObjectService.get_list_of_children(armature_object): child.parent = rigify_object for bone in armature_object.data.bones: name = bone.name if name in child.vertex_groups and not "teeth" in name: vertex_group = child.vertex_groups.get(name) vertex_group.name = "DEF-" + name for modifier in child.modifiers: if modifier.type == 'ARMATURE': modifier.object = rigify_object if delete_after_generate: objs = bpy.data.objects objs.remove(objs[armature_object.name], do_unlink=True) bpy.ops.object.mode_set(mode='EDIT', toggle=False) teethb = RigService.find_edit_bone_by_name("teeth.B", rigify_object) teethb.use_deform = True bpy.ops.object.mode_set(mode='OBJECT', toggle=False) self.report({'INFO'}, "A rig was generated") return {'FINISHED'}