2 Commits

4 changed files with 37 additions and 94 deletions

View File

@ -1,48 +1,6 @@
# Damn Simple Pose Library
In Blender 3.x, a new Asset-based Pose system was introduced. That's fine and dandy, but it was not (and still is not as of Jan 2025) ready to replace the old Action-based Pose Library system.
In Blender 3.x, a new Asset-based Pose system was introduced.
That's fine and dandy, however because of that, the old Pose Library was deprecated and gutted out real quick-like. Too quick.
The former Pose Library was deprecated and gutted rapidly during Blender 3.x, leaving legacy users high and dry. This addon brings the feature back as best as it can in a modern panel. Most, if not all existing Pose Libraries should work without any modifications, little new is introduced outside of string suffixes and mitigations (read further).
## Features
- Supports Blender 3.3 - 4.3 (4.1 recommended).
- New panel interface for interacting with pose libraries, inspired by [gret's Actions Panel feature](https://github.com/greisane/gret?tab=readme-ov-file#animation-actions-panel).
- The older Pose Library list layout is provided as option.
- Operators and data property [that were removed in 3.5](https://projects.blender.org/blender/blender/issues/93406) are ported from C to Python:
- `dspl.apply_pose`
- `dspl.browse_poses`
- `dspl.create_pose_library`
- `dspl.convert_pose_library`
- `dspl.add_pose`
- `dspl.move_pose`
- `dspl.remove_pose`
- `dspl.rename_pose`
- `dspl.unlink_pose_library`
- `Object.pose_library`
## Installation
1. [Download the repository as a zip](https://git.bkspl.me/breakingspell/DamnSimplePoseLibrary/archive/develop.zip), or otherwise clone the repository.
2. Install as an Add-on in Blender via Install -> Zip, and enable.
3. Optionally configure the suffix strings to fit your workflow, and whether the orhpan checker should run at startup.
## Usage
1. Open Sidebar (`N`), and choose the `Pose` tab.
2. Select existing Pose Library from drop-down, or create a new library.
### Hotkeys:
- `Shift + L` - Add/Replace Pose
- `Alt + L` - Browse Poses with Arrow Keys
### Menu Controls
- `Single click` - Apply Pose
- `Shift + Click` - Rename Pose
- `Alt + Click` - Remove Pose
- `Ctrl + Click ` - Select Pose
- Choose `Edit` for fast Move/Rename/Removal
## Considerations
- Opening older scenes will cause existing Pose Libraries to unlink from their former targets and fall into orphan state. They can be re-linked and will retain their link when saved afterwards, but would otherwise disappear if saved without linking or protecting the datablock.
- This is due to the core DNA type `poselib` having been removed, so objects will drop the data. [There is no way to prevent this](https://developer.blender.org/docs/features/core/rna/#internals) as Python ID properties cannot be present at program runtime, only once the add-on is initialized.
- To mitgate, an operator is provided to protect orphaned pose libraries: `dspl.protect_orphan_pose_library`.
- This add-on was made much easier by the `pose_markers` property being retained for converting old pose libraries to the new asset system. If they decide to remove that property as well, there will be a need to improvise an index-based lookup.
This brings it back as best as it can.

View File

@ -3,10 +3,10 @@ from . import gui, operators, common, keymaps
bl_info = \
{
"name": "Damn Simple Pose Library",
"author": "breakingspell",
"version": (0, 1, 0),
"blender": (3, 6, 0),
"description": "Re-implement Pose Library",
"author": "jackie",
"version": (4, 1, 0),
"blender": (3, 5, 0),
"description": "woah",
"category": "Object Data",
}
@ -24,15 +24,12 @@ if _need_reload:
class dsplSettings(bpy.types.PropertyGroup):
new_menu: bpy.props.BoolProperty(
name="New Menu", description="Toggle New Menu", default=True)
name="New Menu", description="Toggle New Menu", default=False)
edit_mode: bpy.props.BoolProperty(
name="Edit Mode", description="Toggle Edit Mode", default=False)
classes = dsplSettings
def pose_libraries_poll(self, action):
if getattr(action, "pose_markers", None):
return True
def register():
from bpy.utils import register_class
@ -40,8 +37,7 @@ def register():
bpy.types.Object.pose_library = bpy.props.PointerProperty(
name="Active Pose Library", description="",
type=bpy.types.Action, override={'LIBRARY_OVERRIDABLE'},
poll=pose_libraries_poll)
type=bpy.types.Action, override={'LIBRARY_OVERRIDABLE'})
bpy.types.Scene.dsplSettings = bpy.props.PointerProperty(
type=dsplSettings, override={'LIBRARY_OVERRIDABLE'})
@ -55,7 +51,6 @@ def unregister():
unregister_class(dsplSettings)
del bpy.types.Scene.dsplSettings
del bpy.types.Object.pose_library
keymaps.unregister()
operators.unregister()

View File

@ -37,17 +37,6 @@ def searchPoseMarker(context, posename, type):
pass
def selectBonesinPose(context, posename, active_marker):
try:
arm_object, pose_library = getArmatureData(context)
for bone in arm_object.pose.bones:
bone.bone.select = False
if findKeyframe(context, bone, active_marker.frame):
bone.bone.select = True
except:
pass
def findFcurve(context, bone_name, transform, index_int):
arm_object, pose_library = getArmatureData(context)
pose_markers = pose_library.pose_markers
@ -73,16 +62,6 @@ def createFcurve(context, bone_name, transform, index_int):
pass
def findKeyframe(context, bone, active_frame):
arm_object, pose_library = getArmatureData(context)
for fcu in pose_library.fcurves:
if fcu.data_path.startswith('pose.bones["'+bone.name+'"]'):
for kp in fcu.keyframe_points:
if kp.co.x == active_frame:
return fcu.data_path
def createKeyframe(context, bone_name, transform, index_int, new_marker, loc):
arm_object, pose_library = getArmatureData(context)
pose_markers = pose_library.pose_markers
@ -105,7 +84,11 @@ def setKeyframesFromBones(context, arm_object, new_marker):
if bone.bone.select or none_selected == True:
bone_name = bone.name
if bone.rotation_mode in ("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"):
if bone.rotation_mode == "XYZ":
rot_mode = "rotation_euler"
elif bone.rotation_mode == "YZX":
rot_mode = "rotation_euler"
elif bone.rotation_mode == "ZXY":
rot_mode = "rotation_euler"
elif bone.rotation_mode == "QUATERNION":
rot_mode = "rotation_quaternion"
@ -166,10 +149,11 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
if bone.bone.select or none_selected == True:
bone_name = bone.name
if findKeyframe(context, bone, active_marker.frame) is None:
continue
if bone.rotation_mode in ("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"):
if bone.rotation_mode == "XYZ":
rot_mode = "rotation_euler"
elif bone.rotation_mode == "YZX":
rot_mode = "rotation_euler"
elif bone.rotation_mode == "ZXY":
rot_mode = "rotation_euler"
elif bone.rotation_mode == "QUATERNION":
rot_mode = "rotation_quaternion"
@ -194,9 +178,21 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
scl_z = findFcurve(context, bone_name, "scale", 2) or 1.0
bone.location = mathutils.Vector((loc_x, loc_y, loc_z))
if rot_mode == "rotation_euler":
if bone.rotation_mode == "XYZ":
bone.rotation_euler = mathutils.Euler(
(rot_x, rot_y, rot_z))
elif bone.rotation_mode == "YZX":
bone.rotation_euler = mathutils.Euler(
(rot_x, rot_y, rot_z))
elif bone.rotation_mode == "ZXY":
bone.rotation_euler = mathutils.Euler(
(rot_z, rot_x, rot_y))
elif bone.rotation_mode == "YXZ":
bone.rotation_euler = mathutils.Euler(
(rot_y, rot_x, rot_z))
elif bone.rotation_mode == "XZY":
bone.rotation_euler = mathutils.Euler(
(rot_x, rot_z, rot_y))
elif rot_mode == "rotation_quaternion":
bone.rotation_quaternion = mathutils.Quaternion(
(rot_w, rot_x, rot_y, rot_z))

View File

@ -21,7 +21,7 @@ class DSPL_OT_CreatePoseLibrary(bpy.types.Operator):
return {'FINISHED'}
# Operator to convert an action to pose library
# Operator to convert a pose library to dspl property
class DSPL_OT_ConvertPoseLibrary(bpy.types.Operator):
@ -254,7 +254,7 @@ class DSPL_OT_MovePose(bpy.types.Operator):
class DSPL_OT_ApplyPose(bpy.types.Operator):
bl_idname = "dspl.apply_pose"
bl_label = "Apply Pose"
bl_description = "Apply Pose (Ctrl+Click to select bones, Shift+Click to rename, Alt+Click to remove)"
bl_description = "Apply Pose (Ctrl+Click to select, Alt+Click to remove)"
bl_options = {'REGISTER', 'UNDO'}
posename: bpy.props.StringProperty()
@ -262,6 +262,7 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
def execute(self, context):
arm_object, pose_library = getArmatureData(context)
pose_markers = pose_library.pose_markers
if self.posename:
@ -283,16 +284,9 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
def invoke(self, context, event):
if event.ctrl:
# Select bones
# Select
arm_object, pose_library = getArmatureData(context)
active_marker = searchPoseMarker(context, posename=self.posename, type="marker")
arm_object.select = True
bpy.context.view_layer.objects.active = arm_object
bpy.ops.object.mode_set(mode='POSE')
selectBonesinPose(context, self.posename, active_marker)
self.execute(context)
pose_library.pose_markers.active_index = searchPoseMarker(context, posename=self.posename, type="index")
return {'FINISHED'}
elif event.alt:
# Remove