Skip to content
Snippets Groups Projects
Commit e529d0d0 authored by Campbell Barton's avatar Campbell Barton
Browse files

fix for rigify with data editing restriction, store runtime props in the window manager.

parent 9d4e9bdc
No related branches found
No related tags found
No related merge requests found
...@@ -125,9 +125,10 @@ def register(): ...@@ -125,9 +125,10 @@ def register():
bpy.types.PoseBone.rigify_type = bpy.props.StringProperty(name="Rigify Type", description="Rig type for this bone.") bpy.types.PoseBone.rigify_type = bpy.props.StringProperty(name="Rigify Type", description="Rig type for this bone.")
bpy.types.PoseBone.rigify_parameters = bpy.props.CollectionProperty(type=RigifyParameters) bpy.types.PoseBone.rigify_parameters = bpy.props.CollectionProperty(type=RigifyParameters)
bpy.types.Scene.rigify_collection = bpy.props.EnumProperty(items=col_enum_list, default="All", name="Rigify Active Collection", description="The selected rig collection") IDStore = bpy.types.WindowManager
bpy.types.Scene.rigify_types = bpy.props.CollectionProperty(type=RigifyName) IDStore.rigify_collection = bpy.props.EnumProperty(items=col_enum_list, default="All", name="Rigify Active Collection", description="The selected rig collection")
bpy.types.Scene.rigify_active_type = bpy.props.IntProperty(name="Rigify Active Type", description="The selected rig type.") IDStore.rigify_types = bpy.props.CollectionProperty(type=RigifyName)
IDStore.rigify_active_type = bpy.props.IntProperty(name="Rigify Active Type", description="The selected rig type.")
metarig_menu.register() metarig_menu.register()
...@@ -136,9 +137,10 @@ def unregister(): ...@@ -136,9 +137,10 @@ def unregister():
del bpy.types.PoseBone.rigify_type del bpy.types.PoseBone.rigify_type
del bpy.types.PoseBone.rigify_parameters del bpy.types.PoseBone.rigify_parameters
del bpy.types.Scene.rigify_collection IDStore = bpy.types.WindowManager
del bpy.types.Scene.rigify_types del IDStore.rigify_collection
del bpy.types.Scene.rigify_active_type del IDStore.rigify_types
del IDStore.rigify_active_type
metarig_menu.unregister() metarig_menu.unregister()
...@@ -45,39 +45,40 @@ class DATA_PT_rigify_buttons(bpy.types.Panel): ...@@ -45,39 +45,40 @@ class DATA_PT_rigify_buttons(bpy.types.Panel):
C = context C = context
layout = self.layout layout = self.layout
obj = context.object obj = context.object
id_store = C.window_manager
if obj.mode in ('POSE', 'OBJECT'): if obj.mode in ('POSE', 'OBJECT'):
row = layout.row() row = layout.row()
row.operator("pose.rigify_generate", text="Generate") row.operator("pose.rigify_generate", text="Generate")
elif obj.mode == 'EDIT': elif obj.mode == 'EDIT':
# Build types list # Build types list
collection_name = str(C.scene.rigify_collection).replace(" ", "") collection_name = str(id_store.rigify_collection).replace(" ", "")
for i in range(0, len(C.scene.rigify_types)): for i in range(0, len(id_store.rigify_types)):
C.scene.rigify_types.remove(0) id_store.rigify_types.remove(0)
for r in rigify.rig_list: for r in rigify.rig_list:
collection = r.split('.')[0] collection = r.split('.')[0]
if collection_name == "All": if collection_name == "All":
a = C.scene.rigify_types.add() a = id_store.rigify_types.add()
a.name = r a.name = r
elif r.startswith(collection_name + '.'): elif r.startswith(collection_name + '.'):
a = C.scene.rigify_types.add() a = id_store.rigify_types.add()
a.name = r a.name = r
elif collection_name == "None" and len(r.split('.')) == 1: elif collection_name == "None" and len(r.split('.')) == 1:
a = C.scene.rigify_types.add() a = id_store.rigify_types.add()
a.name = r a.name = r
## Rig collection field ## Rig collection field
#row = layout.row() #row = layout.row()
#row.prop(C.scene, 'rigify_collection', text="Category") #row.prop(id_store, 'rigify_collection', text="Category")
# Rig type list # Rig type list
row = layout.row() row = layout.row()
row.template_list(C.scene, "rigify_types", C.scene, 'rigify_active_type') row.template_list(id_store, "rigify_types", id_store, 'rigify_active_type')
row = layout.row() row = layout.row()
op = row.operator("armature.metarig_sample_add", text="Add sample") op = row.operator("armature.metarig_sample_add", text="Add sample")
op.metarig_type = C.scene.rigify_types[C.scene.rigify_active_type].name op.metarig_type = id_store.rigify_types[id_store.rigify_active_type].name
class BONE_PT_rigify_buttons(bpy.types.Panel): class BONE_PT_rigify_buttons(bpy.types.Panel):
...@@ -98,31 +99,32 @@ class BONE_PT_rigify_buttons(bpy.types.Panel): ...@@ -98,31 +99,32 @@ class BONE_PT_rigify_buttons(bpy.types.Panel):
def draw(self, context): def draw(self, context):
C = context C = context
id_store = C.window_manager
bone = context.active_pose_bone bone = context.active_pose_bone
collection_name = str(C.scene.rigify_collection).replace(" ", "") collection_name = str(id_store.rigify_collection).replace(" ", "")
rig_name = str(context.active_pose_bone.rigify_type).replace(" ", "") rig_name = str(context.active_pose_bone.rigify_type).replace(" ", "")
layout = self.layout layout = self.layout
# Build types list # Build types list
for i in range(0, len(C.scene.rigify_types)): for i in range(0, len(id_store.rigify_types)):
C.scene.rigify_types.remove(0) id_store.rigify_types.remove(0)
for r in rigify.rig_list: for r in rigify.rig_list:
collection = r.split('.')[0] collection = r.split('.')[0]
if collection_name == "All": if collection_name == "All":
a = C.scene.rigify_types.add() a = id_store.rigify_types.add()
a.name = r a.name = r
elif r.startswith(collection_name + '.'): elif r.startswith(collection_name + '.'):
a = C.scene.rigify_types.add() a = id_store.rigify_types.add()
a.name = r a.name = r
elif collection_name == "None" and len(r.split('.')) == 1: elif collection_name == "None" and len(r.split('.')) == 1:
a = C.scene.rigify_types.add() a = id_store.rigify_types.add()
a.name = r a.name = r
# Rig type field # Rig type field
row = layout.row() row = layout.row()
row.prop_search(bone, "rigify_type", C.scene, "rigify_types", text="Rig type:") row.prop_search(bone, "rigify_type", id_store, "rigify_types", text="Rig type:")
# Rig type parameters / Rig type non-exist alert # Rig type parameters / Rig type non-exist alert
if rig_name != "": if rig_name != "":
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment