Changeset View
Changeset View
Standalone View
Standalone View
rigify/legacy/ui.py
| Show First 20 Lines • Show All 215 Lines • ▼ Show 20 Lines | def draw(self, context): | ||||
| r.operator("armature.rigify_encode_metarig", text="Encode Metarig to Python") | r.operator("armature.rigify_encode_metarig", text="Encode Metarig to Python") | ||||
| r = self.layout.row() | r = self.layout.row() | ||||
| r.operator("armature.rigify_encode_metarig_sample", text="Encode Sample to Python") | r.operator("armature.rigify_encode_metarig_sample", text="Encode Sample to Python") | ||||
| if context.mode == 'EDIT_MESH': | if context.mode == 'EDIT_MESH': | ||||
| r = self.layout.row() | r = self.layout.row() | ||||
| r.operator("mesh.rigify_encode_mesh_widget", text="Encode Mesh Widget to Python") | r.operator("mesh.rigify_encode_mesh_widget", text="Encode Mesh Widget to Python") | ||||
| #~ class INFO_MT_armature_metarig_add(bpy.types.Menu): | #~ class VIEW3D_MT_armature_metarig_add(bpy.types.Menu): | ||||
| #~ bl_idname = "INFO_MT_armature_metarig_add" | #~ bl_idname = "VIEW3D_MT_armature_metarig_add" | ||||
| #~ bl_label = "Meta-Rig" | #~ bl_label = "Meta-Rig" | ||||
| #~ def draw(self, context): | #~ def draw(self, context): | ||||
| #~ import rigify | #~ import rigify | ||||
| #~ layout = self.layout | #~ layout = self.layout | ||||
| #~ layout.operator_context = 'INVOKE_REGION_WIN' | #~ layout.operator_context = 'INVOKE_REGION_WIN' | ||||
| ▲ Show 20 Lines • Show All 65 Lines • ▼ Show 20 Lines | |||||
| class Sample(bpy.types.Operator): | class Sample(bpy.types.Operator): | ||||
| """Create a sample metarig to be modified before generating """ \ | """Create a sample metarig to be modified before generating """ \ | ||||
| """the final rig""" | """the final rig""" | ||||
| bl_idname = "armature.metarig_sample_add" | bl_idname = "armature.metarig_sample_add" | ||||
| bl_label = "Add a sample metarig for a rig type" | bl_label = "Add a sample metarig for a rig type" | ||||
| bl_options = {'UNDO'} | bl_options = {'UNDO'} | ||||
| metarig_type = StringProperty( | metarig_type: StringProperty( | ||||
| name="Type", | name="Type", | ||||
| description="Name of the rig type to generate a sample of", | description="Name of the rig type to generate a sample of", | ||||
| maxlen=128, | maxlen=128, | ||||
| ) | ) | ||||
| def execute(self, context): | def execute(self, context): | ||||
| if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": | if context.mode == 'EDIT_ARMATURE' and self.metarig_type != "": | ||||
| use_global_undo = context.user_preferences.edit.use_global_undo | use_global_undo = context.user_preferences.edit.use_global_undo | ||||
| context.user_preferences.edit.use_global_undo = False | context.user_preferences.edit.use_global_undo = False | ||||
| try: | try: | ||||
| rig = get_rig_type(self.metarig_type) | rig = get_rig_type(self.metarig_type) | ||||
| create_sample = rig.create_sample | create_sample = rig.create_sample | ||||
| ▲ Show 20 Lines • Show All 85 Lines • ▼ Show 20 Lines | def execute(self, context): | ||||
| text = write_widget(context.active_object) | text = write_widget(context.active_object) | ||||
| text_block.write(text) | text_block.write(text) | ||||
| bpy.ops.object.mode_set(mode='EDIT') | bpy.ops.object.mode_set(mode='EDIT') | ||||
| return {'FINISHED'} | return {'FINISHED'} | ||||
| #menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE')) | #menu_func = (lambda self, context: self.layout.menu("VIEW3D_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE')) | ||||
| #from bl_ui import space_info # ensure the menu is loaded first | #from bl_ui import space_info # ensure the menu is loaded first | ||||
| def register(): | def register(): | ||||
| bpy.utils.register_class(DATA_PT_rigify_layer_names) | bpy.utils.register_class(DATA_PT_rigify_layer_names) | ||||
| bpy.utils.register_class(DATA_PT_rigify_buttons) | bpy.utils.register_class(DATA_PT_rigify_buttons) | ||||
| bpy.utils.register_class(BONE_PT_rigify_buttons) | bpy.utils.register_class(BONE_PT_rigify_buttons) | ||||
| bpy.utils.register_class(VIEW3D_PT_tools_rigify_dev) | bpy.utils.register_class(VIEW3D_PT_tools_rigify_dev) | ||||
| bpy.utils.register_class(LayerInit) | bpy.utils.register_class(LayerInit) | ||||
| bpy.utils.register_class(Generate) | bpy.utils.register_class(Generate) | ||||
| bpy.utils.register_class(Sample) | bpy.utils.register_class(Sample) | ||||
| bpy.utils.register_class(EncodeMetarig) | bpy.utils.register_class(EncodeMetarig) | ||||
| bpy.utils.register_class(EncodeMetarigSample) | bpy.utils.register_class(EncodeMetarigSample) | ||||
| bpy.utils.register_class(EncodeWidget) | bpy.utils.register_class(EncodeWidget) | ||||
| #space_info.INFO_MT_armature_add.append(ui.menu_func) | #space_info.VIEW3D_MT_armature_add.append(ui.menu_func) | ||||
| def unregister(): | def unregister(): | ||||
| bpy.utils.unregister_class(DATA_PT_rigify_layer_names) | bpy.utils.unregister_class(DATA_PT_rigify_layer_names) | ||||
| bpy.utils.unregister_class(DATA_PT_rigify_buttons) | bpy.utils.unregister_class(DATA_PT_rigify_buttons) | ||||
| bpy.utils.unregister_class(BONE_PT_rigify_buttons) | bpy.utils.unregister_class(BONE_PT_rigify_buttons) | ||||
| bpy.utils.unregister_class(VIEW3D_PT_tools_rigify_dev) | bpy.utils.unregister_class(VIEW3D_PT_tools_rigify_dev) | ||||
| bpy.utils.unregister_class(LayerInit) | bpy.utils.unregister_class(LayerInit) | ||||
| bpy.utils.unregister_class(Generate) | bpy.utils.unregister_class(Generate) | ||||
| bpy.utils.unregister_class(Sample) | bpy.utils.unregister_class(Sample) | ||||
| bpy.utils.unregister_class(EncodeMetarig) | bpy.utils.unregister_class(EncodeMetarig) | ||||
| bpy.utils.unregister_class(EncodeMetarigSample) | bpy.utils.unregister_class(EncodeMetarigSample) | ||||
| bpy.utils.unregister_class(EncodeWidget) | bpy.utils.unregister_class(EncodeWidget) | ||||