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

git.blender.org/blender-addons.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2022-04-07 12:21:59 +0300
committerSybren A. Stüvel <sybren@blender.org>2022-04-07 12:23:26 +0300
commitbaa581415c7ed23d7c45ef873631748135672683 (patch)
tree046c3c14f5611c86adbb1a93ed3605e76c1b5f8b
parent8bc840015512e6fb7109e8f2e42b176408c15f4d (diff)
Pose Library: better support for legacy pose libraries
Rename "old-style pose library" to "legacy pose library" for consistency with other code, and add pose library conversion operator for use in the "Pose Library (Legacy)" Armature properties panel.
-rw-r--r--pose_library/operators.py39
1 files changed, 37 insertions, 2 deletions
diff --git a/pose_library/operators.py b/pose_library/operators.py
index 1e8a1b5c..a1cccd2c 100644
--- a/pose_library/operators.py
+++ b/pose_library/operators.py
@@ -435,7 +435,7 @@ class POSELIB_OT_apply_pose_asset_for_keymap(Operator):
class POSELIB_OT_convert_old_poselib(Operator):
bl_idname = "poselib.convert_old_poselib"
- bl_label = "Convert Old-Style Pose Library"
+ bl_label = "Convert Legacy Pose Library"
bl_description = "Create a pose asset for each pose marker in the current action"
bl_options = {"REGISTER", "UNDO"}
@@ -446,7 +446,7 @@ class POSELIB_OT_convert_old_poselib(Operator):
cls.poll_message_set("Active object has no Action")
return False
if not action.pose_markers:
- cls.poll_message_set("Action %r is not a old-style pose library" % action.name)
+ cls.poll_message_set("Action %r is not a legacy pose library" % action.name)
return False
return True
@@ -464,11 +464,46 @@ class POSELIB_OT_convert_old_poselib(Operator):
return {'FINISHED'}
+class POSELIB_OT_convert_old_object_poselib(Operator):
+ bl_idname = "poselib.convert_old_object_poselib"
+ bl_label = "Convert Legacy Pose Library"
+ bl_description = "Create a pose asset for each pose marker in this legacy pose library data-block"
+
+ # Mark this one as "internal", as it converts `context.object.pose_library`
+ # instead of its current animation Action.
+ bl_options = {"REGISTER", "UNDO", "INTERNAL"}
+
+ @classmethod
+ def poll(cls, context: Context) -> bool:
+ action = context.object and context.object.pose_library
+ if not action:
+ cls.poll_message_set("Active object has no pose library Action")
+ return False
+ if not action.pose_markers:
+ cls.poll_message_set("Action %r is not a legacy pose library" % action.name)
+ return False
+ return True
+
+ def execute(self, context: Context) -> Set[str]:
+ from . import conversion
+
+ old_poselib = context.object.pose_library
+ new_actions = conversion.convert_old_poselib(old_poselib)
+
+ if not new_actions:
+ self.report({'ERROR'}, "Unable to convert to pose assets")
+ return {'CANCELLED'}
+
+ self.report({'INFO'}, "Converted %d poses to pose assets" % len(new_actions))
+ return {'FINISHED'}
+
+
classes = (
ASSET_OT_assign_action,
POSELIB_OT_apply_pose_asset_for_keymap,
POSELIB_OT_blend_pose_asset_for_keymap,
POSELIB_OT_convert_old_poselib,
+ POSELIB_OT_convert_old_object_poselib,
POSELIB_OT_copy_as_asset,
POSELIB_OT_create_pose_asset,
POSELIB_OT_paste_asset,