[Bf-extensions-cvs] [6ddeca86] master: Rigify 0.5 Bone Groups and Selection Sets support
Lucio Rossi
noreply at git.blender.org
Sun May 14 19:18:00 CEST 2017
Commit: 6ddeca86fb7974fd44eb60724bfbc7935c92cd78
Author: Lucio Rossi
Date: Sun May 14 19:17:22 2017 +0200
Branches: master
https://developer.blender.org/rBA6ddeca86fb7974fd44eb60724bfbc7935c92cd78
Rigify 0.5 Bone Groups and Selection Sets support
===================================================================
M rigify/__init__.py
M rigify/generate.py
M rigify/ui.py
M rigify/utils.py
===================================================================
diff --git a/rigify/__init__.py b/rigify/__init__.py
index 638260e1..2e7953b1 100644
--- a/rigify/__init__.py
+++ b/rigify/__init__.py
@@ -162,14 +162,75 @@ class RigifyName(bpy.types.PropertyGroup):
name = bpy.props.StringProperty()
+class RigifyColorSet(bpy.types.PropertyGroup):
+ name = bpy.props.StringProperty(name="Color Set", default=" ")
+ active = bpy.props.FloatVectorProperty(
+ name="object_color",
+ subtype='COLOR',
+ default=(1.0, 1.0, 1.0),
+ min=0.0, max=1.0,
+ description="color picker"
+ )
+ normal = bpy.props.FloatVectorProperty(
+ name="object_color",
+ subtype='COLOR',
+ default=(1.0, 1.0, 1.0),
+ min=0.0, max=1.0,
+ description="color picker"
+ )
+ select = bpy.props.FloatVectorProperty(
+ name="object_color",
+ subtype='COLOR',
+ default=(1.0, 1.0, 1.0),
+ min=0.0, max=1.0,
+ description="color picker"
+ )
+ standard_colors_lock = bpy.props.BoolProperty(default=True)
+
+
+class RigifySelectionColors(bpy.types.PropertyGroup):
+
+ select = bpy.props.FloatVectorProperty(
+ name="object_color",
+ subtype='COLOR',
+ default=(0.314, 0.784, 1.0),
+ min=0.0, max=1.0,
+ description="color picker"
+ )
+
+ active = bpy.props.FloatVectorProperty(
+ name="object_color",
+ subtype='COLOR',
+ default=(0.549, 1.0, 1.0),
+ min=0.0, max=1.0,
+ description="color picker"
+ )
+
+
class RigifyParameters(bpy.types.PropertyGroup):
name = bpy.props.StringProperty()
class RigifyArmatureLayer(bpy.types.PropertyGroup):
- name = bpy.props.StringProperty(name="Layer Name", default=" ")
- row = bpy.props.IntProperty(name="Layer Row", default=1, min=1, max=32)
+ def get_group(self):
+ if 'group_prop' in self.keys():
+ return self['group_prop']
+ else:
+ return 0
+
+ def set_group(self, value):
+ arm = bpy.context.object.data
+ if value > len(arm.rigify_colors):
+ self['group_prop'] = len(arm.rigify_colors)
+ else:
+ self['group_prop'] = value
+
+ name = bpy.props.StringProperty(name="Layer Name", default=" ")
+ row = bpy.props.IntProperty(name="Layer Row", default=1, min=1, max=32, description='UI row for this layer')
+ set = bpy.props.BoolProperty(name="Selection Set", default=False, description='Add Selection Set for this layer')
+ group = bpy.props.IntProperty(name="Bone Group", default=0, min=0, max=32,
+ get=get_group, set=set_group, description='Assign Bone Group to this layer')
##### REGISTER #####
@@ -179,6 +240,9 @@ def register():
bpy.utils.register_class(RigifyName)
bpy.utils.register_class(RigifyParameters)
+
+ bpy.utils.register_class(RigifyColorSet)
+ bpy.utils.register_class(RigifySelectionColors)
bpy.utils.register_class(RigifyArmatureLayer)
bpy.utils.register_class(RigifyPreferences)
bpy.types.Armature.rigify_layers = bpy.props.CollectionProperty(type=RigifyArmatureLayer)
@@ -186,7 +250,33 @@ def register():
bpy.types.PoseBone.rigify_type = bpy.props.StringProperty(name="Rigify Type", description="Rig type for this bone")
bpy.types.PoseBone.rigify_parameters = bpy.props.PointerProperty(type=RigifyParameters)
- bpy.types.Armature.rigify_layers = bpy.props.CollectionProperty(type=RigifyArmatureLayer)
+ bpy.types.Armature.rigify_colors = bpy.props.CollectionProperty(type=RigifyColorSet)
+
+ bpy.types.Armature.rigify_selection_colors = bpy.props.PointerProperty(type=RigifySelectionColors)
+
+ bpy.types.Armature.rigify_colors_index = bpy.props.IntProperty(default=-1)
+ bpy.types.Armature.rigify_colors_lock = bpy.props.BoolProperty(default=True)
+ bpy.types.Armature.rigify_theme_to_add = bpy.props.EnumProperty(items=(('THEME01', 'THEME01', ''),
+ ('THEME02', 'THEME02', ''),
+ ('THEME03', 'THEME03', ''),
+ ('THEME04', 'THEME04', ''),
+ ('THEME05', 'THEME05', ''),
+ ('THEME06', 'THEME06', ''),
+ ('THEME07', 'THEME07', ''),
+ ('THEME08', 'THEME08', ''),
+ ('THEME09', 'THEME09', ''),
+ ('THEME10', 'THEME10', ''),
+ ('THEME11', 'THEME11', ''),
+ ('THEME12', 'THEME12', ''),
+ ('THEME13', 'THEME13', ''),
+ ('THEME14', 'THEME14', ''),
+ ('THEME15', 'THEME15', ''),
+ ('THEME16', 'THEME16', ''),
+ ('THEME17', 'THEME17', ''),
+ ('THEME18', 'THEME18', ''),
+ ('THEME19', 'THEME19', ''),
+ ('THEME20', 'THEME20', '')
+ ), name='Theme')
IDStore = bpy.types.WindowManager
IDStore.rigify_collection = bpy.props.EnumProperty(items=rig_lists.col_enum_list, default="All",
@@ -220,6 +310,10 @@ def unregister():
bpy.utils.unregister_class(RigifyName)
bpy.utils.unregister_class(RigifyParameters)
+
+ bpy.utils.unregister_class(RigifyColorSet)
+ bpy.utils.unregister_class(RigifySelectionColors)
+
bpy.utils.unregister_class(RigifyArmatureLayer)
bpy.utils.unregister_class(RigifyPreferences)
diff --git a/rigify/generate.py b/rigify/generate.py
index 3fe4e3b8..f86d5eb9 100644
--- a/rigify/generate.py
+++ b/rigify/generate.py
@@ -437,6 +437,12 @@ def generate_rig(context, metarig):
# Run UI script
exec(script.as_string(), {})
+ # Create Selection Sets
+ create_selection_sets(obj, metarig)
+
+ # Create Bone Groups
+ create_bone_groups(obj, metarig)
+
t.tick("The rest: ")
#----------------------------------
# Deconfigure
@@ -445,6 +451,75 @@ def generate_rig(context, metarig):
obj.data.pose_position = 'POSE'
+def create_selection_sets(obj, metarig):
+
+ # Check if selection sets addon is installed
+ if 'bone_selection_groups' not in bpy.context.user_preferences.addons \
+ and 'bone_selection_sets' not in bpy.context.user_preferences.addons:
+ return
+
+ bpy.ops.object.mode_set(mode='POSE')
+
+ bpy.context.scene.objects.active = obj
+ obj.select = True
+ metarig.select = False
+ pbones = obj.pose.bones
+
+ for i, name in enumerate(metarig.data.rigify_layers.keys()):
+ if name == '' or not metarig.data.rigify_layers[i].set:
+ continue
+
+ bpy.ops.pose.select_all(action='DESELECT')
+ for b in pbones:
+ if b.bone.layers[i]:
+ b.bone.select = True
+
+ #bpy.ops.pose.selection_set_add()
+ obj.selection_sets.add()
+ obj.selection_sets[-1].name = name
+ if 'bone_selection_sets' in bpy.context.user_preferences.addons:
+ act_sel_set = obj.selection_sets[-1]
+
+ # iterate only the selected bones in current pose that are not hidden
+ for bone in bpy.context.selected_pose_bones:
+ if bone.name not in act_sel_set.bone_ids:
+ bone_id = act_sel_set.bone_ids.add()
+ bone_id.name = bone.name
+
+
+def create_bone_groups(obj, metarig):
+
+ bpy.ops.object.mode_set(mode='OBJECT')
+ pb = obj.pose.bones
+ layers = metarig.data.rigify_layers
+ groups = metarig.data.rigify_colors
+
+ # Create BGs
+ for l in layers:
+ if l.group == 0:
+ continue
+ g_id = l.group - 1
+ name = groups[g_id].name
+ if name not in obj.pose.bone_groups.keys():
+ bg = obj.pose.bone_groups.new(name)
+ bg.color_set = 'CUSTOM'
+ bg.colors.normal = groups[g_id].normal
+ bg.colors.select = groups[g_id].select
+ bg.colors.active = groups[g_id].active
+
+ for b in pb:
+ try:
+ layer_index = b.bone.layers[:].index(True)
+ except ValueError:
+ continue
+ if layer_index > len(layers) - 1: # bone is on reserved layers
+ continue
+ g_id = layers[layer_index].group - 1
+ if g_id >= 0:
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list