Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'release/scripts/ui/properties_data_armature_rigify.py')
-rw-r--r--release/scripts/ui/properties_data_armature_rigify.py86
1 files changed, 33 insertions, 53 deletions
diff --git a/release/scripts/ui/properties_data_armature_rigify.py b/release/scripts/ui/properties_data_armature_rigify.py
index 8331f2d517b..f7961821277 100644
--- a/release/scripts/ui/properties_data_armature_rigify.py
+++ b/release/scripts/ui/properties_data_armature_rigify.py
@@ -18,16 +18,17 @@
# <pep8 compliant>
import bpy
+from bpy.props import *
-narrowui = bpy.context.user_preferences.view.properties_width_check
-
-class PoseTemplateSettings(bpy.types.IDPropertyGroup):
- pass
+class PoseTemplate(bpy.types.IDPropertyGroup):
+ name = StringProperty(name="Name of the slave", description="", maxlen=64, default="")
-class PoseTemplate(bpy.types.IDPropertyGroup):
- pass
+class PoseTemplateSettings(bpy.types.IDPropertyGroup):
+ templates = CollectionProperty(type=PoseTemplate, name="Templates", description="")
+ active_template_index = IntProperty(name="Index of the active slave", description="", default=-1, min=-1, max=65535)
+ use_generate_deform_rig = BoolProperty(name="Create Deform Rig", description="Create a copy of the metarig, constrainted by the generated rig", default=False)
def metarig_templates():
@@ -40,11 +41,12 @@ class DATA_PT_template(bpy.types.Panel):
bl_space_type = 'PROPERTIES'
bl_region_type = 'WINDOW'
bl_context = "data"
- bl_default_closed = True
+ bl_options = {'DEFAULT_CLOSED'}
templates = []
- def poll(self, context):
+ @classmethod
+ def poll(cls, context):
if not context.armature:
return False
obj = context.object
@@ -85,7 +87,7 @@ class DATA_PT_template(bpy.types.Panel):
row.operator("pose.metarig_validate", text="Check")
row.operator("pose.metarig_graph", text="Graph")
row = layout.row()
- row.prop(pose_templates, "generate_def_rig")
+ row.prop(pose_templates, "use_generate_deform_rig")
row = layout.row()
col = row.column()
@@ -96,16 +98,13 @@ class DATA_PT_template(bpy.types.Panel):
subsubrow.operator("pose.metarig_assign", text="Assign")
subsubrow.operator("pose.metarig_clear", text="Clear")
- subsubrow = subrow.split(percentage=0.8)
- subsubrow.operator("pose.metarig_sample_add", text="Sample").metarig_type = self.templates[pose_templates.active_template_index]
- subsubrow.operator("pose.metarig_sample_add", text="All").metarig_type = "" # self.templates[pose_templates.active_template_index]
-
- sub = row.column(align=True)
- sub.operator("pose.metarig_reload", icon="FILE_REFRESH", text="")
+ if self.templates:
+ subsubrow = subrow.split(percentage=0.8)
+ subsubrow.operator("pose.metarig_sample_add", text="Sample").metarig_type = self.templates[pose_templates.active_template_index]
+ subsubrow.operator("pose.metarig_sample_add", text="All").metarig_type = "" # self.templates[pose_templates.active_template_index]
-
-# operators
-from bpy.props import StringProperty
+ sub = row.column(align=True)
+ sub.operator("pose.metarig_reload", icon="FILE_REFRESH", text="")
class Reload(bpy.types.Operator):
@@ -136,7 +135,7 @@ def rigify_report_exception(operator, exception):
message.append("Incorrect armature for type '%s'" % fn)
message.append(exception.message)
- message.reverse() # XXX - stupid! menu's are upside down!
+ message.reverse() # XXX - stupid! menu's are upside down!
operator.report(set(['INFO']), '\n'.join(message))
@@ -151,7 +150,7 @@ class Generate(bpy.types.Operator):
import rigify
reload(rigify)
- meta_def = context.scene.pose_templates.generate_def_rig
+ meta_def = context.scene.pose_templates.use_generate_deform_rig
try:
rigify.generate_rig(context, context.object, META_DEF=meta_def)
@@ -188,8 +187,8 @@ class Sample(bpy.types.Operator):
def execute(self, context):
import rigify
reload(rigify)
- final = (self.properties.metarig_type == "")
- objects = rigify.generate_test(context, metarig_type=self.properties.metarig_type, GENERATE_FINAL=final)
+ final = (self.metarig_type == "")
+ objects = rigify.generate_test(context, metarig_type=self.metarig_type, GENERATE_FINAL=final)
if len(objects) > 1:
for i, (obj_meta, obj_gen) in enumerate(objects):
@@ -212,7 +211,7 @@ class Graph(bpy.types.Operator):
import bpy
reload(graphviz_export)
obj = bpy.context.object
- path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.utils.clean_name(obj.name)
+ path = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name)
path_dot = path + ".dot"
path_png = path + ".png"
saved = graphviz_export.graph_armature(bpy.context.object, path_dot, CONSTRAINTS=False, DRIVERS=False)
@@ -239,7 +238,7 @@ class AsScript(bpy.types.Operator):
reload(rigify_utils)
obj = context.object
code = rigify_utils.write_meta_rig(obj)
- path = self.properties.filepath
+ path = self.filepath
file = open(path, "w")
file.write(code)
file.close()
@@ -249,8 +248,8 @@ class AsScript(bpy.types.Operator):
def invoke(self, context, event):
import os
obj = context.object
- self.properties.filepath = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.utils.clean_name(obj.name) + ".py"
- wm = context.manager
+ self.filepath = os.path.splitext(bpy.data.filepath)[0] + "-" + bpy.path.clean_name(obj.name) + ".py"
+ wm = context.window_manager
wm.add_fileselect(self)
return {'RUNNING_MODAL'}
@@ -262,7 +261,8 @@ class ActiveAssign(bpy.types.Operator):
bl_idname = "pose.metarig_assign"
bl_label = "Assign to the active posebone"
- def poll(self, context):
+ @classmethod
+ def poll(cls, context):
bone = context.active_pose_bone
return bool(bone and bone.id_data.mode == 'POSE')
@@ -280,7 +280,8 @@ class ActiveClear(bpy.types.Operator):
bl_idname = "pose.metarig_clear"
bl_label = "Metarig Clear Type"
- def poll(self, context):
+ @classmethod
+ def poll(cls, context):
bone = context.active_pose_bone
return bool(bone and bone.id_data.mode == 'POSE')
@@ -304,41 +305,20 @@ class INFO_MT_armature_metarig_add(bpy.types.Menu):
layout.operator_context = 'INVOKE_REGION_WIN'
for submodule_type in rigify.get_submodule_types():
- text = bpy.utils.display_name(submodule_type)
+ text = bpy.path.display_name(submodule_type)
layout.operator("pose.metarig_sample_add", text=text, icon='OUTLINER_OB_ARMATURE').metarig_type = submodule_type
menu_func = (lambda self, context: self.layout.menu("INFO_MT_armature_metarig_add", icon='OUTLINER_OB_ARMATURE'))
-import space_info # ensure the menu is loaded first
+import space_info # ensure the menu is loaded first
def register():
- PoseTemplate.StringProperty(attr="name",
- name="Name of the slave",
- description="",
- maxlen=64,
- default="")
-
-
- PoseTemplateSettings.CollectionProperty(attr="templates", type=PoseTemplate, name="Templates", description="")
- PoseTemplateSettings.IntProperty(attr="active_template_index",
- name="Index of the active slave",
- description="",
- default=-1,
- min=-1,
- max=65535)
-
- PoseTemplateSettings.BoolProperty(attr="generate_def_rig",
- name="Create Deform Rig",
- description="Create a copy of the metarig, constrainted by the generated rig",
- default=False)
-
- bpy.types.Scene.PointerProperty(attr="pose_templates", type=PoseTemplateSettings, name="Pose Templates", description="Pose Template Settings")
-
+ bpy.types.Scene.pose_templates = PointerProperty(type=PoseTemplateSettings, name="Pose Templates", description="Pose Template Settings")
space_info.INFO_MT_armature_add.append(menu_func)
def unregister():
- bpy.types.Scene.RemoveProperty("pose_templates")
+ del bpy.types.Scene.pose_templates
space_info.INFO_MT_armature_add.remove(menu_func)
if __name__ == "__main__":