Rigify for MB-Lab [Addon for an Addon]

This add-on adds a nearly ready-to-use Rigify Meta-Rig for Characters made with the MB-Lab add-on.

After the installation you can find the add-on in the MB-Lab tab in the Properties panel.

usage:

  • create and finalize a character with MB-Lab
  • select the Armature (usually “MBlab_sk<long number>”)
  • click the button “Add Meta-Rig”
    optional:
    • set legs straight and adjust knee offset in y direction
  • Generate Rig (Properties > Data)

to use the weight paint from MB-Lab:

  • select the character mesh
  • exchange the armature object (Properties > Modifiers)
  • click the button “Rename to ‘DEF-*’”

Important:

Rigify in Legacy Mode: Manual weight paint for these bones might be necessary:

"DEF-thumb01_L.01",
"DEF-index01_L.01",
"DEF-middle01_L.01",
"DEF-ring01_L.01",
"DEF-pinky01_L.01",
"DEF-thumb01_R.01",
"DEF-index01_R.01",
"DEF-middle01_R.01",
"DEF-ring01_R.01",
"DEF-pinky01_R.01"

Known issues:

backwards bending knees in some poses/animations with pole_vector = 0
A proper layout for different bones (muscle, helper, MCH, etc.) to Rigify layers is a mission feature for now.


update 0.6.0
add-on renamed
support for muscle rigs
bug fixes

update 0.5.3:
fixed: renaming vertex groups for legacy mode

update 0.5.2:
fixed: renaming vertex groups

update 0.5.1:
added Rigify Legacy Mode compatibility

update 0.5.0:
port to blender 2.8 for MB-Lab

7 Likes

Thank you!

1 Like

update 0.5.1:
added Rigify Legacy Mode compatibility

Hi, i tried to transfer weights from mb to rigify but seems there are bones missing from vertex groups.Mb has fewer bones than rigify that deform. Am i doing something wrong?
Bw i tested on 2.8

Could it be you mean this: (see one of the previous posts): Weight paint for the neck bones “DEF-spine.004” and “DEF-spine.005” needs to be done manually! MB-Lab rig has one neck bone. The default Rigify rig has two neck bones.

I am wondering if I should split that neck bone. Not sure what it will break if I do something like that…

I can merge the vertex groups but though i did something wrong. Anyway thx for this awesome addon!

1 Like

After using the “Rename Vertex Groups” function, you need to do some work. I updated the initial post, to make it more clear what to do.

The addon is nice but I have one bug the arms are not riged after klick MBlab rig to Rigyfy rig 2.7.9 and 2.8

This should be fixed with version 0.5.3.

Maybe you where unlucky and downloaded version 0.5.2. It had a bug in renaming vertex groups and was online for just 2 hours.

1 Like

Thanks! I am all new to Blender, but I finanlly found this - not by using “View3D”/tools - but using shortcut key N.

However I also added the Rigify, and that gives four buttons to press… the first ‘Add Meta rig’ reports “Missing”, when hovering over. The other two, i do not know what they actually do…

When i click the Add button i get this:

1 Like

Thanks for the bug report! I’ll fix it.

edit:
update 0.5.4:
check if Rigify add-on is enabled

Still no luck - perhaps the versions does not match? This is tree different cuts regarding this…

(disregard the paint part… got too much when i cut/paste… :wink: )

1 Like

Well, I forgot to write the description. I just wrote bl_description = "MISSING" in the code and forgot about it. That was unintentional trolling. :rofl: Sorry!

Just ignore the text.

Thanks - I still run into problems! However I think your not to blame… where do I find more on using Rigify?

DanPro has a lot of videos about Rigify on his youtube channel: https://www.youtube.com/user/Dantreige

1 Like

Thanks - just in case, can you tell me why i can not parent two objects. In 2.79 you can drop one object on the other… and it will be shown. In 2.8 you can either link or parent, but you can not see that it is done. Also when you export it… the two objects are separated - drives me nuts!

Found that in that view you can not see the parrenting - you need to go to the other view in the same panel, forgot what it is called… still a silly newbi…

I got the muscle rig working with rigify rig - kind of. There are some issues I could not solve. The knee IK targets are crossed. The feet are rolled in. This makes the feet go unter the ground.


This code is for testing only! Don’t damage your work!

  1. Select the “MBlab_sk_” rig and run this to get the rigify rig:
    This takes a long time.
import bpy
from mathutils import Vector

mblab_rig = None
rigify_rig = None
muscle_rig = None

muscle_parents = {}

subtargets = {}

bpy.ops.object.mode_set(mode='OBJECT')

# Duplicate MB-lab rig
bpy.ops.object.duplicate()
mblab_rig = bpy.context.active_object

# EDIT MODE
bpy.ops.object.mode_set(mode='EDIT')

# Fix disconnected toe
bpy.context.active_object.data.edit_bones['toes_R'].use_connect = True

# Disconnect upperarms
bpy.context.active_object.data.edit_bones['upperarm_L'].use_connect = False
bpy.context.active_object.data.edit_bones['upperarm_R'].use_connect = False

# re-parent thumbs
bpy.context.active_object.data.edit_bones['thumb01_L'].parent = bpy.context.active_object.data.edit_bones['index00_L']
bpy.context.active_object.data.edit_bones['thumb01_R'].parent = bpy.context.active_object.data.edit_bones['index00_R']

# Connect spine with neck
bpy.context.active_object.data.edit_bones['spine03'].tail = bpy.context.active_object.data.edit_bones[
    'neck'].head.copy()
bpy.context.active_object.data.edit_bones['neck'].use_connect = True

# Create heels
for ext in ["_L", "_R"]:
    bone_name = "heel" + ext
    bone_heel = bpy.context.active_object.data.edit_bones.new(bone_name)
    bone_heel.bbone_x = 0.01
    bone_heel.bbone_z = 0.01
    foot_bone = bpy.context.active_object.data.edit_bones["foot" + ext]
    # heel x location relative to foot head
    bone_heel.tail.x = 0.1 if ext == "_L" else -0.1
    heel_head_x = (bone_heel.tail.x - foot_bone.head.x) / 2 + foot_bone.head.x
    heel_tail_x = (foot_bone.head.x - bone_heel.tail.x) / 2 + foot_bone.head.x
    bone_heel.head = Vector((heel_head_x, mblab_rig.location.y, mblab_rig.location.z))
    bone_heel.tail = Vector((heel_tail_x, mblab_rig.location.y, mblab_rig.location.z))
    # parent
    bone_heel.use_connect = False
    bone_heel.parent = foot_bone

# Rename muscle bones on layer 1
for name, bone in bpy.context.active_object.data.edit_bones.items():
    if "rot_helper" in name:
        bone.name = "MCH-" + name
        bone.use_deform = False
    if "muscle" in name:
        if "_H" in name or "_T" in name:
            bone.name = "MCH-" + name
            bone.use_deform = False
        else:
            bone.name = "DEF-" + name

bpy.ops.object.mode_set(mode='POSE')

# Subtargets
for name, bone in bpy.context.active_object.pose.bones.items():
    if "rot_helper" in name or "muscle" in name:
        temp_constraints = {}
        for c_name, constraint in bone.constraints.items():
            sub_name = constraint.subtarget
            if "MCH" not in constraint.subtarget:
                sub_name = "DEF-" + sub_name
            temp_constraints[c_name] = sub_name
        subtargets[name] = temp_constraints

bpy.ops.object.mode_set(mode='EDIT')
# Save the parents
for name, bone in bpy.context.active_object.data.edit_bones.items():
    if "rot_helper" in name or "muscle" in name:
        if "MCH" not in bone.parent.name and "DEF" not in bone.parent.name:
            parent_name = "DEF-" + bone.parent.name
        else:
            parent_name = bone.parent.name
        muscle_parents[name] = parent_name

for name, bone in bpy.context.active_object.data.edit_bones.items():
    if "rot_helper" in name or "muscle" in name:
        bone.parent = None

bpy.ops.object.mode_set(mode='POSE')

# Unlock transforms
for name, bone in bpy.context.active_object.pose.bones.items():
    bone.lock_location[0] = False
    bone.lock_location[1] = False
    bone.lock_location[2] = False
    bone.lock_scale[0] = False
    bone.lock_scale[1] = False
    bone.lock_scale[2] = False

# set rigify types
bpy.context.object.pose.bones["pelvis"].rigify_type = "spines.super_spine"
bpy.context.object.pose.bones["pelvis"].rigify_parameters['neck_pos'] = 5

bpy.context.object.pose.bones["clavicle_L"].rigify_type = "basic.super_copy"
bpy.context.object.pose.bones["clavicle_R"].rigify_type = "basic.super_copy"

bpy.context.object.pose.bones["breast_L"].rigify_type = "basic.super_copy"
bpy.context.object.pose.bones["breast_R"].rigify_type = "basic.super_copy"

for ext in ["_L", "_R"]:
    bone_name = 'thigh' + ext
    bpy.context.object.pose.bones[bone_name].rigify_type = "limbs.super_limb"
    bpy.context.object.pose.bones[bone_name].rigify_parameters.limb_type = 'leg'
    bpy.context.object.pose.bones[bone_name].rigify_parameters.segments = 1
    bpy.context.object.pose.bones[bone_name].rigify_parameters.rotation_axis = 'x'

    bone_name = 'upperarm' + ext
    bpy.context.object.pose.bones[bone_name].rigify_type = "limbs.super_limb"
    bpy.context.object.pose.bones[bone_name].rigify_parameters.limb_type = 'arm'
    bpy.context.object.pose.bones[bone_name].rigify_parameters.segments = 1

    bpy.context.object.pose.bones["index00" + ext].rigify_type = "limbs.super_palm"

    for name in ['thumb01', 'index01', 'middle01', 'ring01', 'pinky01']:
        bone_name = name + ext
        bpy.context.object.pose.bones[bone_name].rigify_type = "limbs.simple_tentacle"

    bpy.context.object.data.bones["breast" + ext].hide = False

bpy.ops.object.mode_set(mode='OBJECT')

# Duplicate MB-lab rig
bpy.ops.object.duplicate()
muscle_rig = bpy.context.active_object

bpy.ops.object.select_all(action='DESELECT')

bpy.context.view_layer.objects.active = muscle_rig

# Delete bones on layer 1
bpy.ops.object.mode_set(mode='EDIT')

bpy.context.object.data.layers[0] = True
bpy.context.object.data.layers[1] = True
for name, bone in bpy.context.active_object.data.edit_bones.items():
    if bone.layers[0]:
        bone.select = True
    else:
        bone.select = False
bpy.ops.armature.delete()

# Move bones to layer 3
for name, bone in bpy.context.active_object.data.edit_bones.items():
    bone.layers[2] = True
for name, bone in bpy.context.active_object.data.edit_bones.items():
    bone.layers[1] = False

bpy.ops.object.mode_set(mode='OBJECT')

# generate rigify rig
bpy.ops.object.select_all(action='DESELECT')
bpy.context.view_layer.objects.active = mblab_rig
bpy.ops.pose.rigify_generate()
rigify_rig = bpy.context.active_object

# add copy rig to rigify rig
muscle_rig.select_set(True)
rigify_rig.select_set(True)
bpy.context.view_layer.objects.active = rigify_rig
bpy.ops.object.join()

bpy.ops.object.mode_set(mode='EDIT')

for bone_name, parent_name in muscle_parents.items():

    # re-parent bones
    bpy.context.active_object.data.edit_bones[bone_name].parent = bpy.context.active_object.data.edit_bones[parent_name]

    # reconnect muscle bones
    if "muscle" in bone_name:
        if not ("_H" in bone_name or "_T" in bone_name):
            bpy.context.active_object.data.edit_bones[bone_name].use_connect = True

bpy.ops.object.mode_set(mode='POSE')

# Subtargets
for bone_name, constraint in subtargets.items():
    for c_name, sub_name in constraint.items():
        bpy.context.object.pose.bones[bone_name].constraints[c_name].subtarget = sub_name

bpy.ops.object.mode_set(mode='OBJECT')

  1. Select the mesh “MBlab_bd_” and run this for renaming the vertex groups:
import bpy

for name, v_group in bpy.context.active_object.vertex_groups.items():
    new_name = "DEF-" + name
    v_group.name = new_name
  1. Replace rig in “mbastlab_armature” modifier.

Hey @DanielEngler am i doing something wrong or the naming of vertex group in blender 2.8 for riggify is no more the same as what the addon changes to.

Please describe more clear what goes wrong!


I’ll start to rewrite the add-on next week. There are too many issues. Starting with fact, that putting two add-ons in the same tab causes trouble. Other issue will be solved, too, like manual wight paint and renaming will be more simple.