Пример #1
0
def register():
    from bpy.utils import register_class

    # Sub-modules.
    ui.register()
    metarig_menu.register()

    # 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 = EnumProperty(items=rig_lists.col_enum_list, default="All",
        name="Rigify Active Collection",
        description="The selected rig collection")

    IDStore.rigify_types = CollectionProperty(type=RigifyName)
    IDStore.rigify_active_type = IntProperty(name="Rigify Active Type", description="The selected rig type")

    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 = 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:
        bpy.context.user_preferences.addons['rigify'].preferences.legacy_mode = True

    # Add rig parameters
    for rig in rig_lists.rig_list:
        r = utils.get_rig_type(rig)
        try:
            r.add_parameters(RigifyParameters)
        except AttributeError:
            pass
Пример #2
0
def register():
    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')

    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_types = bpy.props.CollectionProperty(type=RigifyName)
    IDStore.rigify_active_type = bpy.props.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)

    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)

    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
    for rig in rig_lists.rig_list:
        r = utils.get_rig_type(rig)
        try:
            r.add_parameters(RigifyParameters)
        except AttributeError:
            pass