Ejemplo n.º 1
0
 def set_bone_groups():
     if do_mch:
         bg = Get.bone_group(rig, "BBone FK")
         if not bg:
             bg = New.bone_group(rig, "BBone FK", True)
         bone_mch.bone_group = bg
     if do_start_end:
         bg = Get.bone_group(rig, "BBone Stretch")
         if not bg:
             bg = New.bone_group(rig, "BBone Stretch", True)
         bone_start.bone_group = bone_end.bone_group = bg
         for name in self.center_bones[rig]:
             rig.pose.bones[name].bone_group = bg
     if do_in_out:
         bg = Get.bone_group(rig, "BBone Curve")
         if not bg:
             bg = New.bone_group(rig, "BBone Curve", True)
         bone_in.bone_group = bone_out.bone_group = bg
     if self.hide_bones.get(rig):
         bg = Get.bone_group(rig, "BBone Stretch [Hidden]")
         if not bg:
             bg = New.bone_group(rig, "BBone Stretch [Hidden]",
                                 'THEME20')
         for name in self.hide_bones[rig]:
             rig.pose.bones[name].bone_group = bg
Ejemplo n.º 2
0
Archivo: Set.py Proyecto: Irmitya/zpy
def bone_group(bone, group, color=None):
    """
    Assign bone to group\\
    if group is text, find the group or create it first
    """

    if Is.string(group):
        bgs = bone.id_data.pose.bone_groups
        if group in bgs:
            group = bgs[group]
        else:
            from zpy import New
            group = New.bone_group(bone, name=group)

    if Is.string(color):
        group.color_set = color
        # DEFAULT = regular bone color (not unique)
        # THEME01 - THEME15 = Builtin color palettes
        # THEME16 - THEME20 = Black for user assigned templates
        # CUSTOM = manually set
    elif color is False:
        group.color_set = 'DEFAULT'
    elif color is True:
        from random import randrange as random
        rand = f"{random(1, 15):02}"
        group.color_set = f'THEME{rand}'
    elif color:
        group.color_set = 'CUSTOM'
        gc = group.colors
        if not Is.iterable(color):
            if Is.digit(color):
                color = [[color] * 3] * 3
            else:
                color = [color] * 3
        (gc.normal, gc.select, gc.active) = color

    bone.bone_group = group

    return group