diff --git a/rigify/__init__.py b/rigify/__init__.py index fa93533bd5063cef314bf0cfa840b692855cfdc5..afc3071fbd6fff6f0560dccf14114513dca4975b 100644 --- a/rigify/__init__.py +++ b/rigify/__init__.py @@ -22,7 +22,7 @@ bl_info = { "name": "Rigify", "version": (0, 5), "author": "Nathan Vegdahl, Lucio Rossi, Ivan Cappiello", - "blender": (2, 78, 0), + "blender": (2, 80, 0), "description": "Automatic rigging from building-block components", "location": "Armature properties, Bone properties, View3d tools panel, Armature Add menu", "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.5/Py/" @@ -44,7 +44,15 @@ import bpy import sys import os from bpy.types import AddonPreferences -from bpy.props import BoolProperty +from bpy.props import ( + BoolProperty, + IntProperty, + EnumProperty, + StringProperty, + FloatVectorProperty, + PointerProperty, + CollectionProperty, +) class RigifyPreferences(AddonPreferences): @@ -118,14 +126,13 @@ class RigifyPreferences(AddonPreferences): register() - legacy_mode = BoolProperty( + legacy_mode: BoolProperty( name='Rigify Legacy Mode', description='Select if you want to use Rigify in legacy mode', default=False, update=update_legacy ) - - show_expanded = BoolProperty() + show_expanded: BoolProperty() def draw(self, context): layout = self.layout @@ -158,56 +165,56 @@ class RigifyPreferences(AddonPreferences): class RigifyName(bpy.types.PropertyGroup): - name = bpy.props.StringProperty() + name: 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) + name: StringProperty(name="Color Set", default=" ") + active: FloatVectorProperty( + name="object_color", + subtype='COLOR', + default=(1.0, 1.0, 1.0), + min=0.0, max=1.0, + description="color picker" + ) + normal: FloatVectorProperty( + name="object_color", + subtype='COLOR', + default=(1.0, 1.0, 1.0), + min=0.0, max=1.0, + description="color picker" + ) + select: 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: 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" - ) + select: 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" - ) + active: 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() + name: StringProperty() class RigifyArmatureLayer(bpy.types.PropertyGroup): @@ -225,104 +232,123 @@ class RigifyArmatureLayer(bpy.types.PropertyGroup): 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') + name: StringProperty(name="Layer Name", default=" ") + row: IntProperty(name="Layer Row", default=1, min=1, max=32, description='UI row for this layer') + selset: BoolProperty(name="Selection Set", default=False, description='Add Selection Set for this layer') + group: IntProperty(name="Bone Group", default=0, min=0, max=32, + get=get_group, set=set_group, description='Assign Bone Group to this layer') + ##### REGISTER ##### +classes = ( + RigifyName, + RigifyParameters, + RigifyColorSet, + RigifySelectionColors, + RigifyArmatureLayer, + RigifyPreferences, +) + + def register(): + from bpy.utils import register_class + + # Sub-modules. ui.register() metarig_menu.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) - - 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_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') + # Classes. + for cls in classes: + register_class(cls) + + #Properties. + bpy.types.Armature.rigify_layers = CollectionProperty(type=RigifyArmatureLayer) + + bpy.types.PoseBone.rigify_type = StringProperty(name="Rigify Type", description="Rig type for this bone") + bpy.types.PoseBone.rigify_parameters = PointerProperty(type=RigifyParameters) + + bpy.types.Armature.rigify_colors = CollectionProperty(type=RigifyColorSet) + + bpy.types.Armature.rigify_selection_colors = PointerProperty(type=RigifySelectionColors) + + bpy.types.Armature.rigify_colors_index = IntProperty(default=-1) + bpy.types.Armature.rigify_colors_lock = BoolProperty(default=True) + bpy.types.Armature.rigify_theme_to_add = 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", - name="Rigify Active Collection", - description="The selected rig collection") + IDStore.rigify_collection = EnumProperty(items=rig_lists.col_enum_list, default="All", + name="Rigify Active Collection", + description="The selected rig collection") - IDStore.rigify_types = bpy.props.CollectionProperty(type=RigifyName) - IDStore.rigify_active_type = bpy.props.IntProperty(name="Rigify Active Type", description="The selected rig type") + IDStore.rigify_types = CollectionProperty(type=RigifyName) + IDStore.rigify_active_type = IntProperty(name="Rigify Active Type", description="The selected rig type") - IDStore.rigify_advanced_generation = bpy.props.BoolProperty(name="Advanced Options", - description="Enables/disables advanced options for Rigify rig generation", - default=False) + IDStore.rigify_advanced_generation = BoolProperty(name="Advanced Options", + description="Enables/disables advanced options for Rigify rig generation", + default=False) def update_mode(self, context): if self.rigify_generate_mode == 'new': self.rigify_force_widget_update = False - IDStore.rigify_generate_mode = bpy.props.EnumProperty(name="Rigify Generate Rig Mode", - description="'Generate Rig' mode. In 'overwrite' mode the features of the target rig will be updated as defined by the metarig. In 'new' mode a new rig will be created as defined by the metarig. Current mode", - update=update_mode, - items=(('overwrite', 'overwrite', ''), - ('new', 'new', ''))) - - IDStore.rigify_force_widget_update = bpy.props.BoolProperty(name="Force Widget Update", - description="Forces Rigify to delete and rebuild all the rig widgets. if unset, only missing widgets will be created", - default=False) - - IDStore.rigify_target_rigs = bpy.props.CollectionProperty(type=RigifyName) - IDStore.rigify_target_rig = bpy.props.StringProperty(name="Rigify Target Rig", - description="Defines which rig to overwrite. If unset, a new one called 'rig' will be created", - default="") - - IDStore.rigify_rig_uis = bpy.props.CollectionProperty(type=RigifyName) - IDStore.rigify_rig_ui = bpy.props.StringProperty(name="Rigify Target Rig UI", - description="Defines the UI to overwrite. It should always be the same as the target rig. If unset, 'rig_ui.py' will be used", - default="") - - IDStore.rigify_rig_basename = bpy.props.StringProperty(name="Rigify Rig Name", - description="Defines the name of the Rig. If unset, in 'new' mode 'rig' will be used, in 'overwrite' mode the target rig name will be used", - default="") - - IDStore.rigify_transfer_only_selected = bpy.props.BoolProperty(name="Transfer Only Selected", description="Transfer selected bones only", default=True) - IDStore.rigify_transfer_start_frame = bpy.props.IntProperty(name="Start Frame", description="First Frame to Transfer", default=0, min= 0) - IDStore.rigify_transfer_end_frame = bpy.props.IntProperty(name="End Frame", description="Last Frame to Transfer", default=0, min= 0) - + IDStore.rigify_generate_mode = EnumProperty(name="Rigify Generate Rig Mode", + description="'Generate Rig' mode. In 'overwrite' mode the features of the target rig will be updated as defined by the metarig. In 'new' mode a new rig will be created as defined by the metarig. Current mode", + update=update_mode, + items=( ('overwrite', 'overwrite', ''), + ('new', 'new', ''))) + + IDStore.rigify_force_widget_update = BoolProperty(name="Force Widget Update", + description="Forces Rigify to delete and rebuild all the rig widgets. if unset, only missing widgets will be created", + default=False) + + IDStore.rigify_target_rigs = CollectionProperty(type=RigifyName) + IDStore.rigify_target_rig = StringProperty(name="Rigify Target Rig", + description="Defines which rig to overwrite. If unset, a new one called 'rig' will be created", + default="") + + IDStore.rigify_rig_uis = CollectionProperty(type=RigifyName) + IDStore.rigify_rig_ui = StringProperty(name="Rigify Target Rig UI", + description="Defines the UI to overwrite. It should always be the same as the target rig. If unset, 'rig_ui.py' will be used", + default="") + + IDStore.rigify_rig_basename = StringProperty(name="Rigify Rig Name", + description="Defines the name of the Rig. If unset, in 'new' mode 'rig' will be used, in 'overwrite' mode the target rig name will be used", + default="") + + IDStore.rigify_transfer_only_selected = BoolProperty( + name="Transfer Only Selected", + description="Transfer selected bones only", default=True) + IDStore.rigify_transfer_start_frame = IntProperty( + name="Start Frame", + description="First Frame to Transfer", default=0, min= 0) + IDStore.rigify_transfer_end_frame = IntProperty( + name="End Frame", + description="Last Frame to Transfer", default=0, min= 0) + + # Update legacy on restart or reload. if (ui and 'legacy' in str(ui)) or bpy.context.user_preferences.addons['rigify'].preferences.legacy_mode: - # update legacy on restart or reload bpy.context.user_preferences.addons['rigify'].preferences.legacy_mode = True # Add rig parameters @@ -335,6 +361,9 @@ def register(): def unregister(): + from bpy.utils import unregister_class + + # Properties. del bpy.types.PoseBone.rigify_type del bpy.types.PoseBone.rigify_parameters @@ -354,14 +383,10 @@ def unregister(): del IDStore.rigify_transfer_start_frame del IDStore.rigify_transfer_end_frame - 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) + # Classes. + for cls in classes: + unregister_class(cls) + # Sub-modules. metarig_menu.unregister() ui.unregister() diff --git a/rigify/legacy/__init__.py b/rigify/legacy/__init__.py index 6e6f751c7461ba52437bc1d17723b8ba083b1368..029d877e5126f4a5cc5b25a7219708de1ce66a84 100644 --- a/rigify/legacy/__init__.py +++ b/rigify/legacy/__init__.py @@ -45,16 +45,16 @@ import bpy class RigifyName(bpy.types.PropertyGroup): - name = bpy.props.StringProperty() + name: bpy.props.StringProperty() class RigifyParameters(bpy.types.PropertyGroup): - name = bpy.props.StringProperty() + 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) + name: bpy.props.StringProperty(name="Layer Name", default=" ") + row: bpy.props.IntProperty(name="Layer Row", default=1, min=1, max=32) ##### REGISTER ##### diff --git a/rigify/legacy/rigs/basic/copy.py b/rigify/legacy/rigs/basic/copy.py index 50a25767df1769374e8376ea9a2d86afb76e8fad..65c5ff3172b739357269a1b40ac8edf5cf2793ae 100644 --- a/rigify/legacy/rigs/basic/copy.py +++ b/rigify/legacy/rigs/basic/copy.py @@ -88,8 +88,8 @@ def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - params.make_control = bpy.props.BoolProperty(name="Control", default=True, description="Create a control bone for the copy") - params.make_deform = bpy.props.BoolProperty(name="Deform", default=True, description="Create a deform bone for the copy") + params.make_control: bpy.props.BoolProperty(name="Control", default=True, description="Create a control bone for the copy") + params.make_deform: bpy.props.BoolProperty(name="Deform", default=True, description="Create a deform bone for the copy") def parameters_ui(layout, params): diff --git a/rigify/legacy/rigs/basic/copy_chain.py b/rigify/legacy/rigs/basic/copy_chain.py index 4e4262846924799500f8c936e50f020ae9b18e54..25013c0e371c5d6a24ecd37d6929db7418be00c9 100644 --- a/rigify/legacy/rigs/basic/copy_chain.py +++ b/rigify/legacy/rigs/basic/copy_chain.py @@ -127,8 +127,8 @@ def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - params.make_controls = bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy") - params.make_deforms = bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy") + params.make_controls: bpy.props.BoolProperty(name="Controls", default=True, description="Create control bones for the copy") + params.make_deforms: bpy.props.BoolProperty(name="Deform", default=True, description="Create deform bones for the copy") def parameters_ui(layout, params): diff --git a/rigify/legacy/rigs/pitchipoy/super_copy.py b/rigify/legacy/rigs/pitchipoy/super_copy.py index 27e887750ce5c369e36f1cbfa9f62a0408fba3eb..5a60ed0433c21c48e657cf7bfba24094870836b6 100644 --- a/rigify/legacy/rigs/pitchipoy/super_copy.py +++ b/rigify/legacy/rigs/pitchipoy/super_copy.py @@ -91,7 +91,7 @@ def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - params.make_control = bpy.props.BoolProperty( + params.make_control: bpy.props.BoolProperty( name = "Control", default = True, description = "Create a control bone for the copy" diff --git a/rigify/legacy/rigs/pitchipoy/super_face.py b/rigify/legacy/rigs/pitchipoy/super_face.py index 341596a1a059ad935eca201c188062fd13e3a2a4..79aa5e021e6c8565c9050e4f96b6fde0151c45ef 100644 --- a/rigify/legacy/rigs/pitchipoy/super_face.py +++ b/rigify/legacy/rigs/pitchipoy/super_face.py @@ -1016,26 +1016,26 @@ def add_parameters(params): """ #Setting up extra layers for the tweak bones - params.primary_layers_extra = bpy.props.BoolProperty( + params.primary_layers_extra: bpy.props.BoolProperty( name = "primary_layers_extra", default = True, description = "" - ) - params.primary_layers = bpy.props.BoolVectorProperty( + ) + params.primary_layers: bpy.props.BoolVectorProperty( size = 32, description = "Layers for the 1st tweak controls to be on", default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) - params.secondary_layers_extra = bpy.props.BoolProperty( + ) + params.secondary_layers_extra: bpy.props.BoolProperty( name = "secondary_layers_extra", default = True, description = "" - ) - params.secondary_layers = bpy.props.BoolVectorProperty( + ) + params.secondary_layers: bpy.props.BoolVectorProperty( size = 32, description = "Layers for the 2nd tweak controls to be on", default = tuple( [ i == 1 for i in range(0, 32) ] ) - ) + ) def parameters_ui(layout, params): diff --git a/rigify/legacy/ui.py b/rigify/legacy/ui.py index dec5b73c8a8e8462959f7b95fd9784ebf636c6be..033d6516203605763cfac669a541b0e77d0be530 100644 --- a/rigify/legacy/ui.py +++ b/rigify/legacy/ui.py @@ -304,11 +304,11 @@ class Sample(bpy.types.Operator): bl_label = "Add a sample metarig for a rig type" bl_options = {'UNDO'} - metarig_type = StringProperty( - name="Type", - description="Name of the rig type to generate a sample of", - maxlen=128, - ) + metarig_type: StringProperty( + name="Type", + description="Name of the rig type to generate a sample of", + maxlen=128, + ) def execute(self, context): if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": diff --git a/rigify/metarig_menu.py b/rigify/metarig_menu.py index 6b12abad49ef2619826d572b4ab2d966e9a548d0..153c2cb962404529c0ab7de31884dcb2958c3602 100644 --- a/rigify/metarig_menu.py +++ b/rigify/metarig_menu.py @@ -159,25 +159,33 @@ for metarig_class in metarig_classes: arm_sub = next((e for e in armature_submenus if e.bl_label == metarig_class + ' (submenu)'), '') arm_sub.operators.append((mop.bl_idname, name,)) + +### Registering ### + + def register(): + from bpy.utils import register_class + for cl in metarig_ops: for mop, name in metarig_ops[cl]: - bpy.utils.register_class(mop) + register_class(mop) for arm_sub in armature_submenus: - bpy.utils.register_class(arm_sub) + register_class(arm_sub) for mf in menu_funcs: bpy.types.INFO_MT_armature_add.append(mf) def unregister(): + from bpy.utils import unregister_class + for cl in metarig_ops: for mop, name in metarig_ops[cl]: - bpy.utils.unregister_class(mop) + unregister_class(mop) for arm_sub in armature_submenus: - bpy.utils.unregister_class(arm_sub) + unregister_class(arm_sub) for mf in menu_funcs: bpy.types.INFO_MT_armature_add.remove(mf) diff --git a/rigify/rig_ui_template.py b/rigify/rig_ui_template.py index 3cdda311ca84bc48a24bde8ed27b44a64808fd19..bbbc06dcd70fe727efa657db569589c01eac0fd9 100644 --- a/rigify/rig_ui_template.py +++ b/rigify/rig_ui_template.py @@ -20,6 +20,7 @@ UI_SLIDERS = ''' import bpy +from bpy.props import StringProperty from mathutils import Matrix, Vector from math import acos, pi, radians @@ -600,13 +601,13 @@ class Rigify_Arm_FK2IK(bpy.types.Operator): bl_label = "Rigify Snap FK arm to IK" bl_options = {'UNDO'} - uarm_fk = bpy.props.StringProperty(name="Upper Arm FK Name") - farm_fk = bpy.props.StringProperty(name="Forerm FK Name") - hand_fk = bpy.props.StringProperty(name="Hand FK Name") + uarm_fk: StringProperty(name="Upper Arm FK Name") + farm_fk: StringProperty(name="Forerm FK Name") + hand_fk: StringProperty(name="Hand FK Name") - uarm_ik = bpy.props.StringProperty(name="Upper Arm IK Name") - farm_ik = bpy.props.StringProperty(name="Forearm IK Name") - hand_ik = bpy.props.StringProperty(name="Hand IK Name") + uarm_ik: StringProperty(name="Upper Arm IK Name") + farm_ik: StringProperty(name="Forearm IK Name") + hand_ik: StringProperty(name="Hand IK Name") @classmethod def poll(cls, context): @@ -629,16 +630,16 @@ class Rigify_Arm_IK2FK(bpy.types.Operator): bl_label = "Rigify Snap IK arm to FK" bl_options = {'UNDO'} - uarm_fk = bpy.props.StringProperty(name="Upper Arm FK Name") - farm_fk = bpy.props.StringProperty(name="Forerm FK Name") - hand_fk = bpy.props.StringProperty(name="Hand FK Name") + uarm_fk: StringProperty(name="Upper Arm FK Name") + farm_fk: StringProperty(name="Forerm FK Name") + hand_fk: StringProperty(name="Hand FK Name") - uarm_ik = bpy.props.StringProperty(name="Upper Arm IK Name") - farm_ik = bpy.props.StringProperty(name="Forearm IK Name") - hand_ik = bpy.props.StringProperty(name="Hand IK Name") - pole = bpy.props.StringProperty(name="Pole IK Name") + uarm_ik: StringProperty(name="Upper Arm IK Name") + farm_ik: StringProperty(name="Forearm IK Name") + hand_ik: StringProperty(name="Hand IK Name") + pole : StringProperty(name="Pole IK Name") - main_parent = bpy.props.StringProperty(name="Main Parent", default="") + main_parent: StringProperty(name="Main Parent", default="") @classmethod def poll(cls, context): @@ -661,15 +662,15 @@ class Rigify_Leg_FK2IK(bpy.types.Operator): bl_label = "Rigify Snap FK leg to IK" bl_options = {'UNDO'} - thigh_fk = bpy.props.StringProperty(name="Thigh FK Name") - shin_fk = bpy.props.StringProperty(name="Shin FK Name") - foot_fk = bpy.props.StringProperty(name="Foot FK Name") - mfoot_fk = bpy.props.StringProperty(name="MFoot FK Name") + thigh_fk: StringProperty(name="Thigh FK Name") + shin_fk: StringProperty(name="Shin FK Name") + foot_fk: StringProperty(name="Foot FK Name") + mfoot_fk: StringProperty(name="MFoot FK Name") - thigh_ik = bpy.props.StringProperty(name="Thigh IK Name") - shin_ik = bpy.props.StringProperty(name="Shin IK Name") - foot_ik = bpy.props.StringProperty(name="Foot IK Name") - mfoot_ik = bpy.props.StringProperty(name="MFoot IK Name") + thigh_ik: StringProperty(name="Thigh IK Name") + shin_ik: StringProperty(name="Shin IK Name") + foot_ik: StringProperty(name="Foot IK Name") + mfoot_ik: StringProperty(name="MFoot IK Name") @classmethod def poll(cls, context): @@ -692,18 +693,18 @@ class Rigify_Leg_IK2FK(bpy.types.Operator): bl_label = "Rigify Snap IK leg to FK" bl_options = {'UNDO'} - thigh_fk = bpy.props.StringProperty(name="Thigh FK Name") - shin_fk = bpy.props.StringProperty(name="Shin FK Name") - mfoot_fk = bpy.props.StringProperty(name="MFoot FK Name") - foot_fk = bpy.props.StringProperty(name="Foot FK Name", default="") - thigh_ik = bpy.props.StringProperty(name="Thigh IK Name") - shin_ik = bpy.props.StringProperty(name="Shin IK Name") - foot_ik = bpy.props.StringProperty(name="Foot IK Name") - footroll = bpy.props.StringProperty(name="Foot Roll Name") - pole = bpy.props.StringProperty(name="Pole IK Name") - mfoot_ik = bpy.props.StringProperty(name="MFoot IK Name") + thigh_fk: StringProperty(name="Thigh FK Name") + shin_fk: StringProperty(name="Shin FK Name") + mfoot_fk: StringProperty(name="MFoot FK Name") + foot_fk: StringProperty(name="Foot FK Name", default="") + thigh_ik: StringProperty(name="Thigh IK Name") + shin_ik: StringProperty(name="Shin IK Name") + foot_ik: StringProperty(name="Foot IK Name") + footroll: StringProperty(name="Foot Roll Name") + pole: StringProperty(name="Pole IK Name") + mfoot_ik: StringProperty(name="MFoot IK Name") - main_parent = bpy.props.StringProperty(name="Main Parent", default="") + main_parent: StringProperty(name="Main Parent", default="") @classmethod def poll(cls, context): @@ -726,13 +727,14 @@ class Rigify_Rot2PoleSwitch(bpy.types.Operator): bl_idname = "pose.rigify_rot2pole_" + rig_id bl_label = "Rotation - Pole toggle" bl_description = "Toggles IK chain between rotation and pole target" - bone_name = bpy.props.StringProperty(default='') - limb_type = bpy.props.StringProperty(name="Limb Type") - controls = bpy.props.StringProperty(name="Controls string") - ik_ctrl = bpy.props.StringProperty(name="IK Controls string") - fk_ctrl = bpy.props.StringProperty(name="FK Controls string") - parent = bpy.props.StringProperty(name="Parent name") - pole = bpy.props.StringProperty(name="Pole name") + + bone_name: StringProperty(default='') + limb_type: StringProperty(name="Limb Type") + controls: StringProperty(name="Controls string") + ik_ctrl: StringProperty(name="IK Controls string") + fk_ctrl: StringProperty(name="FK Controls string") + parent: StringProperty(name="Parent name") + pole: StringProperty(name="Pole name") def execute(self, context): rig = context.object @@ -841,23 +843,26 @@ class RigLayers(bpy.types.Panel): UI_REGISTER = ''' +classes = ( + Rigify_Arm_FK2IK, + Rigify_Arm_IK2FK, + Rigify_Leg_FK2IK, + Rigify_Leg_IK2FK, + Rigify_Rot2PoleSwitch, + RigUI, + RigLayers, +) + def register(): - bpy.utils.register_class(Rigify_Arm_FK2IK) - bpy.utils.register_class(Rigify_Arm_IK2FK) - bpy.utils.register_class(Rigify_Leg_FK2IK) - bpy.utils.register_class(Rigify_Leg_IK2FK) - bpy.utils.register_class(Rigify_Rot2PoleSwitch) - bpy.utils.register_class(RigUI) - bpy.utils.register_class(RigLayers) + from bpy.utils import register_class + for cls in classes: + register_class(cls) + def unregister(): - bpy.utils.unregister_class(Rigify_Arm_FK2IK) - bpy.utils.unregister_class(Rigify_Arm_IK2FK) - bpy.utils.unregister_class(Rigify_Leg_FK2IK) - bpy.utils.unregister_class(Rigify_Leg_IK2FK) - bpy.utils.register_class(Rigify_Rot2PoleSwitch) - bpy.utils.unregister_class(RigUI) - bpy.utils.unregister_class(RigLayers) + from bpy.utils import unregister_class + for cls in classes: + unregister_class(cls) register() ''' diff --git a/rigify/rigs/basic/super_copy.py b/rigify/rigs/basic/super_copy.py index b204534683907868fc7e74551ed508f00c832ece..20a70bc600ada314f9f04f86285a570955c56f53 100644 --- a/rigify/rigs/basic/super_copy.py +++ b/rigify/rigs/basic/super_copy.py @@ -92,7 +92,7 @@ def add_parameters(params): """ Add the parameters of this rig type to the RigifyParameters PropertyGroup """ - params.make_control = bpy.props.BoolProperty( + params.make_control: bpy.props.BoolProperty( name = "Control", default = True, description = "Create a control bone for the copy" diff --git a/rigify/rot_mode.py b/rigify/rot_mode.py index 22def2246fb6742d735b01e957b78037ce54bdc8..d5e5a71e6f7ea5d40f1bca56229280d681d3ea21 100644 --- a/rigify/rot_mode.py +++ b/rigify/rot_mode.py @@ -38,6 +38,10 @@ blender.stackexchange.com/questions/40711/how-to-convert-quaternions-keyframes-t # "category": "Animation"} import bpy +from bpy.props import ( + BoolProperty, + EnumProperty, +) order_list = ['QUATERNION', 'XYZ', 'XZY', 'YXZ', 'YZX', 'ZXY', 'ZYX'] @@ -326,9 +330,19 @@ class CONVERT_OT_quat2eu_all_actions(bpy.types.Operator): return {'FINISHED'} +### Registering ### + +classes = ( + ToolsPanel, + CONVERT_OT_quat2eu_current_action, + CONVERT_OT_quat2eu_all_actions, +) + + def register(): - IDStore = bpy.types.WindowManager + from bpy.utils import register_class + # Properties. items = [('QUATERNION', 'QUATERNION', 'QUATERNION'), ('XYZ', 'XYZ', 'XYZ'), ('XZY', 'XZY', 'XZY'), @@ -336,24 +350,27 @@ def register(): ('YZX', 'YZX', 'YZX'), ('ZXY', 'ZXY', 'ZXY'), ('ZYX', 'ZYX', 'ZYX')] + bpy.types.Scene.order_list = EnumProperty( + items=items, name='Convert to', + description="The target rotation mode", default='QUATERNION') - bpy.types.Scene.order_list = bpy.props.EnumProperty(items=items, name='Convert to', - description="The target rotation mode", default='QUATERNION') + IDStore = bpy.types.WindowManager + IDStore.rigify_convert_only_selected = BoolProperty( + name="Convert Only Selected", + description="Convert selected bones only", default=True) - IDStore.rigify_convert_only_selected = bpy.props.BoolProperty( - name="Convert Only Selected", description="Convert selected bones only", default=True) + # Classes. + for cls in classes: + register_class(cls) - bpy.utils.register_class(ToolsPanel) - bpy.utils.register_class(CONVERT_OT_quat2eu_current_action) - bpy.utils.register_class(CONVERT_OT_quat2eu_all_actions) def unregister(): - IDStore = bpy.types.WindowManager + from bpy.utils import unregister_class - bpy.utils.unregister_class(ToolsPanel) - bpy.utils.unregister_class(CONVERT_OT_quat2eu_current_action) - bpy.utils.unregister_class(CONVERT_OT_quat2eu_all_actions) + # Classes. + for cls in classes: + unregister_class(cls) + # Properties. + IDStore = bpy.types.WindowManager del IDStore.rigify_convert_only_selected - -# bpy.utils.register_module(__name__) diff --git a/rigify/ui.py b/rigify/ui.py index ce66da963299b13ddb458420ffeb7ea52b95261d..3a155c0dcf190d61cacfd595ddc77195cec9784c 100644 --- a/rigify/ui.py +++ b/rigify/ui.py @@ -19,7 +19,13 @@ # <pep8 compliant> import bpy -from bpy.props import StringProperty +from bpy.props import ( + BoolProperty, + IntProperty, + EnumProperty, + StringProperty +) + from mathutils import Color from .utils import get_rig_type, MetarigError @@ -395,28 +401,29 @@ class DATA_OT_rigify_bone_group_add_theme(bpy.types.Operator): bl_label = "Rigify Add Bone Group color set from Theme" bl_options = {"REGISTER", "UNDO"} - theme = 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') + theme: 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') @classmethod def poll(cls, context): @@ -448,7 +455,7 @@ class DATA_OT_rigify_bone_group_remove(bpy.types.Operator): bl_idname = "armature.rigify_bone_group_remove" bl_label = "Rigify Remove Bone Group color set" - idx = bpy.props.IntProperty() + idx: IntProperty() @classmethod def poll(cls, context): @@ -794,18 +801,17 @@ class SwitchToLegacy(bpy.types.Operator): class Sample(bpy.types.Operator): - """Create a sample metarig to be modified before generating """ \ - """the final rig""" + """Create a sample metarig to be modified before generating the final rig""" bl_idname = "armature.metarig_sample_add" bl_label = "Add a sample metarig for a rig type" bl_options = {'UNDO'} - metarig_type = StringProperty( - name="Type", - description="Name of the rig type to generate a sample of", - maxlen=128, - ) + metarig_type: StringProperty( + name="Type", + description="Name of the rig type to generate a sample of", + maxlen=128, + ) def execute(self, context): if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": @@ -1074,20 +1080,20 @@ def IktoFk(rig, window='ALL'): break -def clearAnimation(act, type, names): +def clearAnimation(act, anim_type, names): bones = [] for group in names: if names[group]['limb_type'] == 'arm': - if type == 'IK': + if anim_type == 'IK': bones.extend([names[group]['controls'][0], names[group]['controls'][4]]) - elif type == 'FK': + elif anim_type == 'FK': bones.extend([names[group]['controls'][1], names[group]['controls'][2], names[group]['controls'][3]]) else: - if type == 'IK': + if anim_type == 'IK': bones.extend([names[group]['controls'][0], names[group]['controls'][6], names[group]['controls'][5], names[group]['controls'][4]]) - elif type == 'FK': + elif anim_type == 'FK': bones.extend([names[group]['controls'][1], names[group]['controls'][2], names[group]['controls'][3], names[group]['controls'][4]]) FCurves = [] @@ -1271,7 +1277,8 @@ class OBJECT_OT_ClearAnimation(bpy.types.Operator): bl_idname = "rigify.clear_animation" bl_label = "Clear Animation" bl_description = "Clear Animation For FK or IK Bones" - type = StringProperty() + + anim_type: StringProperty() def execute(self, context): @@ -1286,7 +1293,7 @@ class OBJECT_OT_ClearAnimation(bpy.types.Operator): if not act: return {'FINISHED'} - clearAnimation(act, self.type, names=get_limb_generated_names(rig)) + clearAnimation(act, self.anim_type, names=get_limb_generated_names(rig)) finally: context.user_preferences.edit.use_global_undo = use_global_undo return {'FINISHED'} @@ -1296,11 +1303,12 @@ class OBJECT_OT_Rot2Pole(bpy.types.Operator): bl_idname = "rigify.rotation_pole" bl_label = "Rotation - Pole toggle" bl_description = "Toggles IK chain between rotation and pole target" - bone_name = bpy.props.StringProperty(default='') - window = bpy.props.StringProperty(default='ALL') - toggle = bpy.props.BoolProperty(default=True) - value = bpy.props.BoolProperty(default=True) - bake = bpy.props.BoolProperty(default=True) + + bone_name: StringProperty(default='') + window: StringProperty(default='ALL') + toggle: BoolProperty(default=True) + value: BoolProperty(default=True) + bake: BoolProperty(default=True) def execute(self, context): rig = context.object @@ -1313,74 +1321,60 @@ class OBJECT_OT_Rot2Pole(bpy.types.Operator): return {'FINISHED'} +### Registering ### + + +classes = ( + DATA_OT_rigify_add_bone_groups, + DATA_OT_rigify_use_standard_colors, + DATA_OT_rigify_apply_selection_colors, + DATA_OT_rigify_bone_group_add, + DATA_OT_rigify_bone_group_add_theme, + DATA_OT_rigify_bone_group_remove, + DATA_OT_rigify_bone_group_remove_all, + DATA_UL_rigify_bone_groups, + DATA_MT_rigify_bone_groups_specials, + DATA_PT_rigify_bone_groups, + DATA_PT_rigify_layer_names, + DATA_PT_rigify_buttons, + BONE_PT_rigify_buttons, + VIEW3D_PT_rigify_animation_tools, + VIEW3D_PT_tools_rigify_dev, + LayerInit, + Generate, + UpgradeMetarigTypes, + SwitchToLegacy, + Sample, + EncodeMetarig, + EncodeMetarigSample, + EncodeWidget, + OBJECT_OT_GetFrameRange, + OBJECT_OT_FK2IK, + OBJECT_OT_IK2FK, + OBJECT_OT_TransferFKtoIK, + OBJECT_OT_TransferIKtoFK, + OBJECT_OT_ClearAnimation, + OBJECT_OT_Rot2Pole, +) + + def register(): + from bpy.utils import register_class - bpy.utils.register_class(DATA_OT_rigify_add_bone_groups) - bpy.utils.register_class(DATA_OT_rigify_use_standard_colors) - bpy.utils.register_class(DATA_OT_rigify_apply_selection_colors) - bpy.utils.register_class(DATA_OT_rigify_bone_group_add) - bpy.utils.register_class(DATA_OT_rigify_bone_group_add_theme) - bpy.utils.register_class(DATA_OT_rigify_bone_group_remove) - bpy.utils.register_class(DATA_OT_rigify_bone_group_remove_all) - bpy.utils.register_class(DATA_UL_rigify_bone_groups) - bpy.utils.register_class(DATA_MT_rigify_bone_groups_specials) - bpy.utils.register_class(DATA_PT_rigify_bone_groups) - bpy.utils.register_class(DATA_PT_rigify_layer_names) - bpy.utils.register_class(DATA_PT_rigify_buttons) - bpy.utils.register_class(BONE_PT_rigify_buttons) - bpy.utils.register_class(VIEW3D_PT_rigify_animation_tools) - bpy.utils.register_class(VIEW3D_PT_tools_rigify_dev) - bpy.utils.register_class(LayerInit) - bpy.utils.register_class(Generate) - bpy.utils.register_class(UpgradeMetarigTypes) - bpy.utils.register_class(SwitchToLegacy) - bpy.utils.register_class(Sample) - bpy.utils.register_class(EncodeMetarig) - bpy.utils.register_class(EncodeMetarigSample) - bpy.utils.register_class(EncodeWidget) - bpy.utils.register_class(OBJECT_OT_GetFrameRange) - bpy.utils.register_class(OBJECT_OT_FK2IK) - bpy.utils.register_class(OBJECT_OT_IK2FK) - bpy.utils.register_class(OBJECT_OT_TransferFKtoIK) - bpy.utils.register_class(OBJECT_OT_TransferIKtoFK) - bpy.utils.register_class(OBJECT_OT_ClearAnimation) - bpy.utils.register_class(OBJECT_OT_Rot2Pole) + # Classes. + for cls in classes: + register_class(cls) + # Sub-modules. rot_mode.register() def unregister(): + from bpy.utils import unregister_class - bpy.utils.unregister_class(DATA_OT_rigify_add_bone_groups) - bpy.utils.unregister_class(DATA_OT_rigify_use_standard_colors) - bpy.utils.unregister_class(DATA_OT_rigify_apply_selection_colors) - bpy.utils.unregister_class(DATA_OT_rigify_bone_group_add) - bpy.utils.unregister_class(DATA_OT_rigify_bone_group_add_theme) - bpy.utils.unregister_class(DATA_OT_rigify_bone_group_remove) - bpy.utils.unregister_class(DATA_OT_rigify_bone_group_remove_all) - bpy.utils.unregister_class(DATA_UL_rigify_bone_groups) - bpy.utils.unregister_class(DATA_MT_rigify_bone_groups_specials) - bpy.utils.unregister_class(DATA_PT_rigify_bone_groups) - bpy.utils.unregister_class(DATA_PT_rigify_layer_names) - bpy.utils.unregister_class(DATA_PT_rigify_buttons) - bpy.utils.unregister_class(BONE_PT_rigify_buttons) - bpy.utils.unregister_class(VIEW3D_PT_rigify_animation_tools) - bpy.utils.unregister_class(VIEW3D_PT_tools_rigify_dev) - bpy.utils.unregister_class(LayerInit) - bpy.utils.unregister_class(Generate) - bpy.utils.unregister_class(UpgradeMetarigTypes) - bpy.utils.unregister_class(SwitchToLegacy) - bpy.utils.unregister_class(Sample) - bpy.utils.unregister_class(EncodeMetarig) - bpy.utils.unregister_class(EncodeMetarigSample) - bpy.utils.unregister_class(EncodeWidget) - bpy.utils.unregister_class(OBJECT_OT_GetFrameRange) - bpy.utils.unregister_class(OBJECT_OT_FK2IK) - bpy.utils.unregister_class(OBJECT_OT_IK2FK) - bpy.utils.unregister_class(OBJECT_OT_TransferFKtoIK) - bpy.utils.unregister_class(OBJECT_OT_TransferIKtoFK) - bpy.utils.unregister_class(OBJECT_OT_ClearAnimation) - bpy.utils.unregister_class(OBJECT_OT_Rot2Pole) - + # Sub-modules. rot_mode.unregister() + # Classes. + for cls in classes: + unregister_class(cls)