Rename project to Yet Another Pose Library (for now)
This commit is contained in:
24
README.md
24
README.md
@ -1,4 +1,4 @@
|
|||||||
# Damn Simple Pose Library
|
# Yet Another 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, but it was not (and still is not as of Jan 2025) ready to replace the old Action-based Pose Library system.
|
||||||
|
|
||||||
@ -10,19 +10,19 @@ The former Pose Library was deprecated and gutted rapidly during Blender 3.x, le
|
|||||||
- 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).
|
- 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.
|
- 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:
|
- 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`
|
- `yapl.apply_pose`
|
||||||
- `dspl.browse_poses`
|
- `yapl.browse_poses`
|
||||||
- `dspl.create_pose_library`
|
- `yapl.create_pose_library`
|
||||||
- `dspl.convert_pose_library`
|
- `yapl.convert_pose_library`
|
||||||
- `dspl.add_pose`
|
- `yapl.add_pose`
|
||||||
- `dspl.move_pose`
|
- `yapl.move_pose`
|
||||||
- `dspl.remove_pose`
|
- `yapl.remove_pose`
|
||||||
- `dspl.rename_pose`
|
- `yapl.rename_pose`
|
||||||
- `dspl.unlink_pose_library`
|
- `yapl.unlink_pose_library`
|
||||||
- `Object.pose_library`
|
- `Object.pose_library`
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
1. [Download the repository as a zip](https://git.bkspl.me/breakingspell/DamnSimplePoseLibrary/archive/develop.zip), or otherwise clone the repository.
|
1. [Download the repository as a zip](https://git.bkspl.me/breakingspell/YetAnotherPoseLibrary/archive/develop.zip), or otherwise clone the repository.
|
||||||
2. Install as an Add-on in Blender via Install -> Zip, and enable.
|
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.
|
3. Optionally configure the suffix strings to fit your workflow, and whether the orhpan checker should run at startup.
|
||||||
|
|
||||||
@ -43,6 +43,6 @@ The former Pose Library was deprecated and gutted rapidly during Blender 3.x, le
|
|||||||
## Considerations
|
## 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.
|
- 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.
|
- 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`.
|
- To mitgate, an operator is provided to protect orphaned pose libraries: `yapl.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 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.
|
||||||
|
18
__init__.py
18
__init__.py
@ -2,11 +2,11 @@ import bpy
|
|||||||
from . import gui, operators, common, keymaps
|
from . import gui, operators, common, keymaps
|
||||||
bl_info = \
|
bl_info = \
|
||||||
{
|
{
|
||||||
"name": "Damn Simple Pose Library",
|
"name": "Yet Another Pose Library",
|
||||||
"author": "breakingspell",
|
"author": "breakingspell",
|
||||||
"version": (0, 1, 0),
|
"version": (0, 1, 0),
|
||||||
"blender": (3, 6, 0),
|
"blender": (3, 6, 0),
|
||||||
"description": "Re-implement Pose Library",
|
"description": "Re-implement 3.x legacy Pose Library",
|
||||||
"category": "Object Data",
|
"category": "Object Data",
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -22,13 +22,13 @@ if _need_reload:
|
|||||||
operators = importlib.reload(operators)
|
operators = importlib.reload(operators)
|
||||||
|
|
||||||
|
|
||||||
class dsplSettings(bpy.types.PropertyGroup):
|
class yaplSettings(bpy.types.PropertyGroup):
|
||||||
new_menu: bpy.props.BoolProperty(
|
new_menu: bpy.props.BoolProperty(
|
||||||
name="New Menu", description="Toggle New Menu", default=True)
|
name="New Menu", description="Toggle New Menu", default=True)
|
||||||
edit_mode: bpy.props.BoolProperty(
|
edit_mode: bpy.props.BoolProperty(
|
||||||
name="Edit Mode", description="Toggle Edit Mode", default=False)
|
name="Edit Mode", description="Toggle Edit Mode", default=False)
|
||||||
|
|
||||||
classes = dsplSettings
|
classes = yaplSettings
|
||||||
|
|
||||||
def pose_libraries_poll(self, action):
|
def pose_libraries_poll(self, action):
|
||||||
if getattr(action, "pose_markers", None):
|
if getattr(action, "pose_markers", None):
|
||||||
@ -36,15 +36,15 @@ def pose_libraries_poll(self, action):
|
|||||||
|
|
||||||
def register():
|
def register():
|
||||||
from bpy.utils import register_class
|
from bpy.utils import register_class
|
||||||
register_class(dsplSettings)
|
register_class(yaplSettings)
|
||||||
|
|
||||||
bpy.types.Object.pose_library = bpy.props.PointerProperty(
|
bpy.types.Object.pose_library = bpy.props.PointerProperty(
|
||||||
name="Active Pose Library", description="",
|
name="Active Pose Library", description="",
|
||||||
type=bpy.types.Action, override={'LIBRARY_OVERRIDABLE'},
|
type=bpy.types.Action, override={'LIBRARY_OVERRIDABLE'},
|
||||||
poll=pose_libraries_poll)
|
poll=pose_libraries_poll)
|
||||||
|
|
||||||
bpy.types.Scene.dsplSettings = bpy.props.PointerProperty(
|
bpy.types.Scene.yaplSettings = bpy.props.PointerProperty(
|
||||||
type=dsplSettings, override={'LIBRARY_OVERRIDABLE'})
|
type=yaplSettings, override={'LIBRARY_OVERRIDABLE'})
|
||||||
|
|
||||||
gui.register()
|
gui.register()
|
||||||
operators.register()
|
operators.register()
|
||||||
@ -52,9 +52,9 @@ def register():
|
|||||||
|
|
||||||
def unregister():
|
def unregister():
|
||||||
from bpy.utils import unregister_class
|
from bpy.utils import unregister_class
|
||||||
unregister_class(dsplSettings)
|
unregister_class(yaplSettings)
|
||||||
|
|
||||||
del bpy.types.Scene.dsplSettings
|
del bpy.types.Scene.yaplSettings
|
||||||
del bpy.types.Object.pose_library
|
del bpy.types.Object.pose_library
|
||||||
|
|
||||||
keymaps.unregister()
|
keymaps.unregister()
|
||||||
|
@ -93,7 +93,7 @@ def set_keyframes_from_bones(context, arm_object, new_marker):
|
|||||||
elif bone.rotation_mode == "QUATERNION":
|
elif bone.rotation_mode == "QUATERNION":
|
||||||
rot_mode = "rotation_quaternion"
|
rot_mode = "rotation_quaternion"
|
||||||
else:
|
else:
|
||||||
self.report({'WARNING'}, "DSPL: Unsupported bone: " + bone.name + ": " + bone.rotation_mode)
|
self.report({'WARNING'}, "YAPL: Unsupported bone: " + bone.name + ": " + bone.rotation_mode)
|
||||||
rot_mode = None
|
rot_mode = None
|
||||||
|
|
||||||
loc_x = bone.location[0]
|
loc_x = bone.location[0]
|
||||||
@ -158,7 +158,7 @@ def set_bones_from_keyframes(context, arm_object, active_marker):
|
|||||||
elif bone.rotation_mode == "QUATERNION":
|
elif bone.rotation_mode == "QUATERNION":
|
||||||
rot_mode = "rotation_quaternion"
|
rot_mode = "rotation_quaternion"
|
||||||
else:
|
else:
|
||||||
self.report({'WARNING'}, "DSPL: Unsupported bone: " + bone.name + ": " + bone.rotation_mode)
|
self.report({'WARNING'}, "YAPL: Unsupported bone: " + bone.name + ": " + bone.rotation_mode)
|
||||||
rot_mode = None
|
rot_mode = None
|
||||||
|
|
||||||
loc_x = find_fcurve(context, bone_name, "location", 0) or 0.0
|
loc_x = find_fcurve(context, bone_name, "location", 0) or 0.0
|
||||||
|
78
gui.py
78
gui.py
@ -2,9 +2,9 @@ import bpy
|
|||||||
from .common import *
|
from .common import *
|
||||||
|
|
||||||
|
|
||||||
class DATA_PT_DSPLPanel(bpy.types.Panel):
|
class DATA_PT_YaplPanel(bpy.types.Panel):
|
||||||
bl_label = "Damn Simple Pose Library"
|
bl_label = "Yet Another Pose Library"
|
||||||
bl_id = "DATA_PT_DSPLPanel"
|
bl_id = "DATA_PT_YaplPanel"
|
||||||
bl_space_type = 'VIEW_3D'
|
bl_space_type = 'VIEW_3D'
|
||||||
bl_region_type = 'UI'
|
bl_region_type = 'UI'
|
||||||
bl_category = 'Pose'
|
bl_category = 'Pose'
|
||||||
@ -14,11 +14,11 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
|||||||
return len(bpy.context.selected_objects)
|
return len(bpy.context.selected_objects)
|
||||||
|
|
||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
dspl_panel_layout = self.layout
|
yapl_panel_layout = self.layout
|
||||||
dsplsettings = bpy.context.scene.dsplSettings
|
yaplsettings = bpy.context.scene.yaplSettings
|
||||||
|
|
||||||
# Detect Armature object and parent
|
# Detect Armature object and parent
|
||||||
armature_layout = dspl_panel_layout.column(align=True)
|
armature_layout = yapl_panel_layout.column(align=True)
|
||||||
active_obj = context.active_object
|
active_obj = context.active_object
|
||||||
arm_object, pose_library = get_armature_data(context)
|
arm_object, pose_library = get_armature_data(context)
|
||||||
pose_library_action = get_armature_action(context)
|
pose_library_action = get_armature_action(context)
|
||||||
@ -33,35 +33,35 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
|||||||
if pose_library or pose_library_action:
|
if pose_library or pose_library_action:
|
||||||
if pose_library and not pose_library_action:
|
if pose_library and not pose_library_action:
|
||||||
armature_layout.template_ID(
|
armature_layout.template_ID(
|
||||||
arm_object, "pose_library", new="dspl.create_pose_library", unlink="dspl.unlink_pose_library")
|
arm_object, "pose_library", new="yapl.create_pose_library", unlink="yapl.unlink_pose_library")
|
||||||
|
|
||||||
elif pose_library_action and not pose_library:
|
elif pose_library_action and not pose_library:
|
||||||
armature_layout.template_ID(
|
armature_layout.template_ID(
|
||||||
arm_object.animation_data, "action", new="dspl.create_pose_library")
|
arm_object.animation_data, "action", new="yapl.create_pose_library")
|
||||||
armature_layout.label(
|
armature_layout.label(
|
||||||
text="Pose Library detected as Action")
|
text="Pose Library detected as Action")
|
||||||
armature_layout.label(
|
armature_layout.label(
|
||||||
text="You should convert to avoid problems")
|
text="You should convert to avoid problems")
|
||||||
armature_layout.operator(
|
armature_layout.operator(
|
||||||
"dspl.convert_pose_library", icon='PLUGIN', text="Convert to Pose Library")
|
"yapl.convert_pose_library", icon='PLUGIN', text="Convert to Pose Library")
|
||||||
|
|
||||||
elif pose_library and pose_library_action:
|
elif pose_library and pose_library_action:
|
||||||
armature_layout.template_ID(
|
armature_layout.template_ID(
|
||||||
arm_object, "pose_library", new="dspl.create_pose_library")
|
arm_object, "pose_library", new="yapl.create_pose_library")
|
||||||
armature_layout.label(text="Pose Library is opened as Action")
|
armature_layout.label(text="Pose Library is opened as Action")
|
||||||
armature_layout.label(text="Keyframes will affect pose")
|
armature_layout.label(text="Keyframes will affect pose")
|
||||||
armature_layout.operator(
|
armature_layout.operator(
|
||||||
"dspl.convert_pose_library", icon='PLUGIN', text="Unlink from Action")
|
"yapl.convert_pose_library", icon='PLUGIN', text="Unlink from Action")
|
||||||
|
|
||||||
|
|
||||||
# List poses in pose library
|
# List poses in pose library
|
||||||
if pose_library:
|
if pose_library:
|
||||||
pose_box_layout = dspl_panel_layout.column()
|
pose_box_layout = yapl_panel_layout.column()
|
||||||
|
|
||||||
# Menu switcher
|
# Menu switcher
|
||||||
pose_box_menu_switcher_layout = pose_box_layout.row()
|
pose_box_menu_switcher_layout = pose_box_layout.row()
|
||||||
pose_box_menu_switcher_layout.prop(
|
pose_box_menu_switcher_layout.prop(
|
||||||
dsplsettings, "new_menu", icon='PMARKER_ACT', text="New Menu", toggle=True)
|
yaplsettings, "new_menu", icon='PMARKER_ACT', text="New Menu", toggle=True)
|
||||||
|
|
||||||
# Quick controls
|
# Quick controls
|
||||||
quick_pose_controls_layout = pose_box_layout.column()
|
quick_pose_controls_layout = pose_box_layout.column()
|
||||||
@ -71,16 +71,16 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
|||||||
quick_apply_layout = quick_pose_controls_layout.split(
|
quick_apply_layout = quick_pose_controls_layout.split(
|
||||||
align=True)
|
align=True)
|
||||||
quick_apply_layout.operator(
|
quick_apply_layout.operator(
|
||||||
"dspl.browse_poses", icon='CON_ARMATURE', text="Browse")
|
"yapl.browse_poses", icon='CON_ARMATURE', text="Browse")
|
||||||
if dsplsettings.new_menu == False:
|
if yaplsettings.new_menu == False:
|
||||||
quick_apply_layout.operator(
|
quick_apply_layout.operator(
|
||||||
"dspl.apply_pose", icon='ARMATURE_DATA', text="Apply Pose").posename = pose_library.pose_markers.active.name
|
"yapl.apply_pose", icon='ARMATURE_DATA', text="Apply Pose").posename = pose_library.pose_markers.active.name
|
||||||
else:
|
else:
|
||||||
quick_apply_layout.prop(dsplsettings,
|
quick_apply_layout.prop(yaplsettings,
|
||||||
"edit_mode", icon='GREASEPENCIL', text="Edit", toggle=True)
|
"edit_mode", icon='GREASEPENCIL', text="Edit", toggle=True)
|
||||||
|
|
||||||
# New menu
|
# New menu
|
||||||
if dsplsettings.new_menu == True:
|
if yaplsettings.new_menu == True:
|
||||||
pose_button_layout = pose_box_layout.row()
|
pose_button_layout = pose_box_layout.row()
|
||||||
pose_button_entries_layout = pose_button_layout.column(align=True)
|
pose_button_entries_layout = pose_button_layout.column(align=True)
|
||||||
for pm in pose_library.pose_markers:
|
for pm in pose_library.pose_markers:
|
||||||
@ -88,27 +88,27 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
|||||||
|
|
||||||
# Selected indicator
|
# Selected indicator
|
||||||
selected = pm.frame == pose_library.pose_markers.active.frame
|
selected = pm.frame == pose_library.pose_markers.active.frame
|
||||||
if dsplsettings.edit_mode == False:
|
if yaplsettings.edit_mode == False:
|
||||||
row.label(text="", icon='PMARKER_ACT' if selected else 'PMARKER_SEL')
|
row.label(text="", icon='PMARKER_ACT' if selected else 'PMARKER_SEL')
|
||||||
|
|
||||||
# Pose operator buttons
|
# Pose operator buttons
|
||||||
if dsplsettings.edit_mode == True:
|
if yaplsettings.edit_mode == True:
|
||||||
row.operator('dspl.rename_pose', text=pm.name).posename = pm.name
|
row.operator('yapl.rename_pose', text=pm.name).posename = pm.name
|
||||||
else:
|
else:
|
||||||
row.operator('dspl.apply_pose', text=pm.name).posename = pm.name
|
row.operator('yapl.apply_pose', text=pm.name).posename = pm.name
|
||||||
|
|
||||||
if dsplsettings.edit_mode == True:
|
if yaplsettings.edit_mode == True:
|
||||||
movebuttondown = row.operator("dspl.move_pose", icon='TRIA_DOWN', text="")
|
movebuttondown = row.operator("yapl.move_pose", icon='TRIA_DOWN', text="")
|
||||||
movebuttondown.direction = "DOWN"
|
movebuttondown.direction = "DOWN"
|
||||||
movebuttondown.posename = pm.name
|
movebuttondown.posename = pm.name
|
||||||
movebuttonup = row.operator("dspl.move_pose", icon='TRIA_UP', text="")
|
movebuttonup = row.operator("yapl.move_pose", icon='TRIA_UP', text="")
|
||||||
movebuttonup.direction = "UP"
|
movebuttonup.direction = "UP"
|
||||||
movebuttonup.posename = pm.name
|
movebuttonup.posename = pm.name
|
||||||
|
|
||||||
row.operator("dspl.remove_pose", icon='REMOVE', text="").posename = pm.name
|
row.operator("yapl.remove_pose", icon='REMOVE', text="").posename = pm.name
|
||||||
|
|
||||||
# Old menu
|
# Old menu
|
||||||
elif dsplsettings.new_menu == False:
|
elif yaplsettings.new_menu == False:
|
||||||
pose_list_layout = pose_box_layout.column()
|
pose_list_layout = pose_box_layout.column()
|
||||||
|
|
||||||
# Pose list
|
# Pose list
|
||||||
@ -123,20 +123,20 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
|||||||
"wm.call_menu", icon='ADD', text="").name = "OBJECT_MT_AddPoseMenu"
|
"wm.call_menu", icon='ADD', text="").name = "OBJECT_MT_AddPoseMenu"
|
||||||
if pose_library.pose_markers.active:
|
if pose_library.pose_markers.active:
|
||||||
pose_ops_layout.operator(
|
pose_ops_layout.operator(
|
||||||
"dspl.remove_pose", icon='REMOVE', text="")
|
"yapl.remove_pose", icon='REMOVE', text="")
|
||||||
pose_ops_layout.operator(
|
pose_ops_layout.operator(
|
||||||
"dspl.apply_pose", icon='ARMATURE_DATA', text=""
|
"yapl.apply_pose", icon='ARMATURE_DATA', text=""
|
||||||
).posename = pose_library.pose_markers.active.name
|
).posename = pose_library.pose_markers.active.name
|
||||||
pose_ops_layout.operator(
|
pose_ops_layout.operator(
|
||||||
"dspl.move_pose", icon='TRIA_UP', text="").direction = "UP"
|
"yapl.move_pose", icon='TRIA_UP', text="").direction = "UP"
|
||||||
pose_ops_layout.operator(
|
pose_ops_layout.operator(
|
||||||
"dspl.move_pose", icon='TRIA_DOWN', text="").direction = "DOWN"
|
"yapl.move_pose", icon='TRIA_DOWN', text="").direction = "DOWN"
|
||||||
|
|
||||||
else:
|
else:
|
||||||
armature_layout.label(
|
armature_layout.label(
|
||||||
text="No Action or Pose Library detected")
|
text="No Action or Pose Library detected")
|
||||||
armature_layout.template_ID(
|
armature_layout.template_ID(
|
||||||
arm_object, "pose_library", new="dspl.create_pose_library")
|
arm_object, "pose_library", new="yapl.create_pose_library")
|
||||||
|
|
||||||
else:
|
else:
|
||||||
armature_layout.label(text="No armature or parent selected")
|
armature_layout.label(text="No armature or parent selected")
|
||||||
@ -149,11 +149,11 @@ class OBJECT_MT_AddPoseMenu(bpy.types.Menu):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
arm_object, pose_library = get_armature_data(context)
|
arm_object, pose_library = get_armature_data(context)
|
||||||
|
|
||||||
dspl_add_menu_layout = self.layout
|
yapl_add_menu_layout = self.layout
|
||||||
dspl_add_menu_layout.operator(
|
yapl_add_menu_layout.operator(
|
||||||
"dspl.add_pose", icon='ADD', text="Add New Pose")
|
"yapl.add_pose", icon='ADD', text="Add New Pose")
|
||||||
if len(pose_library.pose_markers):
|
if len(pose_library.pose_markers):
|
||||||
dspl_add_menu_layout.menu(
|
yapl_add_menu_layout.menu(
|
||||||
"OBJECT_MT_ReplacePoseMenu", text="Replace Existing Pose", icon="DECORATE_OVERRIDE")
|
"OBJECT_MT_ReplacePoseMenu", text="Replace Existing Pose", icon="DECORATE_OVERRIDE")
|
||||||
|
|
||||||
|
|
||||||
@ -164,15 +164,15 @@ class OBJECT_MT_ReplacePoseMenu(bpy.types.Menu):
|
|||||||
def draw(self, context):
|
def draw(self, context):
|
||||||
arm_object, pose_library = get_armature_data(context)
|
arm_object, pose_library = get_armature_data(context)
|
||||||
|
|
||||||
dspl_replace_menu_layout = self.layout
|
yapl_replace_menu_layout = self.layout
|
||||||
for pm in pose_library.pose_markers:
|
for pm in pose_library.pose_markers:
|
||||||
op = dspl_replace_menu_layout.operator("dspl.add_pose", text=pm.name, icon="PMARKER")
|
op = yapl_replace_menu_layout.operator("yapl.add_pose", text=pm.name, icon="PMARKER")
|
||||||
op.replace = True
|
op.replace = True
|
||||||
op.posename = pm.name
|
op.posename = pm.name
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
DATA_PT_DSPLPanel,
|
DATA_PT_YaplPanel,
|
||||||
OBJECT_MT_AddPoseMenu,
|
OBJECT_MT_AddPoseMenu,
|
||||||
OBJECT_MT_ReplacePoseMenu,
|
OBJECT_MT_ReplacePoseMenu,
|
||||||
)
|
)
|
||||||
|
@ -15,7 +15,7 @@ def register_keymaps():
|
|||||||
|
|
||||||
# Browse Poses
|
# Browse Poses
|
||||||
km = wm.keyconfigs.addon.keymaps.new(name='Pose', space_type='EMPTY')
|
km = wm.keyconfigs.addon.keymaps.new(name='Pose', space_type='EMPTY')
|
||||||
kmi = km.keymap_items.new('dspl.browse_poses', 'L', 'PRESS', alt=True)
|
kmi = km.keymap_items.new('yapl.browse_poses', 'L', 'PRESS', alt=True)
|
||||||
addon_keymaps.append((km, kmi))
|
addon_keymaps.append((km, kmi))
|
||||||
|
|
||||||
def unregister_keymaps():
|
def unregister_keymaps():
|
||||||
|
88
operators.py
88
operators.py
@ -6,8 +6,8 @@ from .common import *
|
|||||||
# Operator to create a new pose library
|
# Operator to create a new pose library
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_CreatePoseLibrary(bpy.types.Operator):
|
class YAPL_OT_CreatePoseLibrary(bpy.types.Operator):
|
||||||
bl_idname = "dspl.create_pose_library"
|
bl_idname = "yapl.create_pose_library"
|
||||||
bl_label = "Create Pose Library"
|
bl_label = "Create Pose Library"
|
||||||
bl_description = "Create Pose Library"
|
bl_description = "Create Pose Library"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -24,8 +24,8 @@ class DSPL_OT_CreatePoseLibrary(bpy.types.Operator):
|
|||||||
# Operator to convert an action to pose library
|
# Operator to convert an action to pose library
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_ConvertPoseLibrary(bpy.types.Operator):
|
class YAPL_OT_ConvertPoseLibrary(bpy.types.Operator):
|
||||||
bl_idname = "dspl.convert_pose_library"
|
bl_idname = "yapl.convert_pose_library"
|
||||||
bl_label = "Convert Pose Library"
|
bl_label = "Convert Pose Library"
|
||||||
bl_description = "Convert Pose Library"
|
bl_description = "Convert Pose Library"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -42,14 +42,14 @@ class DSPL_OT_ConvertPoseLibrary(bpy.types.Operator):
|
|||||||
# Operator to add keyframes and marker to pose library
|
# Operator to add keyframes and marker to pose library
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_AddPose(bpy.types.Operator):
|
class YAPL_OT_AddPose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.add_pose"
|
bl_idname = "yapl.add_pose"
|
||||||
bl_label = "Add Pose"
|
bl_label = "Add Pose"
|
||||||
bl_description = "Add Pose"
|
bl_description = "Add Pose"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
posename: bpy.props.StringProperty(default="Pose")
|
posename: bpy.props.StringProperty(default="Pose")
|
||||||
replace: bpy.props.BoolProperty(name="Replace", description="Replace existing pose", default=False, options={'SKIP_SAVE'})
|
replace: bpy.props.BoolProperty(name="Replace", description="Replace existing pose", default=False, options={'SKIP_SAVE', 'HIDDEN'})
|
||||||
|
|
||||||
def execute(self, context):
|
def execute(self, context):
|
||||||
arm_object, pose_library = get_armature_data(context)
|
arm_object, pose_library = get_armature_data(context)
|
||||||
@ -85,7 +85,7 @@ class DSPL_OT_AddPose(bpy.types.Operator):
|
|||||||
pose_library.pose_markers.active = pose_markers[pose_name]
|
pose_library.pose_markers.active = pose_markers[pose_name]
|
||||||
bpy.context.area.tag_redraw()
|
bpy.context.area.tag_redraw()
|
||||||
|
|
||||||
self.report({'INFO'}, "DSPL: Added " + pose_markers[new_name].name + " to frame " + str(pose_markers[new_name].frame))
|
self.report({'INFO'}, "YAPL: Added " + pose_markers[new_name].name + " to frame " + str(pose_markers[new_name].frame))
|
||||||
|
|
||||||
else:
|
else:
|
||||||
pose_markers = pose_library.pose_markers
|
pose_markers = pose_library.pose_markers
|
||||||
@ -107,7 +107,7 @@ class DSPL_OT_AddPose(bpy.types.Operator):
|
|||||||
|
|
||||||
set_keyframes_from_bones(context, arm_object, new_marker)
|
set_keyframes_from_bones(context, arm_object, new_marker)
|
||||||
|
|
||||||
self.report({'INFO'}, "DSPL: Replaced " + pose_markers[new_name].name + " on frame " + str(pose_markers[new_name].frame))
|
self.report({'INFO'}, "YAPL: Replaced " + pose_markers[new_name].name + " on frame " + str(pose_markers[new_name].frame))
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -115,8 +115,8 @@ class DSPL_OT_AddPose(bpy.types.Operator):
|
|||||||
# Operator to remove keyframes and marker
|
# Operator to remove keyframes and marker
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_RemovePose(bpy.types.Operator):
|
class YAPL_OT_RemovePose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.remove_pose"
|
bl_idname = "yapl.remove_pose"
|
||||||
bl_label = "Remove Pose"
|
bl_label = "Remove Pose"
|
||||||
bl_description = "Remove Pose"
|
bl_description = "Remove Pose"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -155,7 +155,7 @@ class DSPL_OT_RemovePose(bpy.types.Operator):
|
|||||||
pose_library.pose_markers.active = next_marker
|
pose_library.pose_markers.active = next_marker
|
||||||
pose_library.pose_markers.active_index = next_index
|
pose_library.pose_markers.active_index = next_index
|
||||||
|
|
||||||
self.report({'INFO'}, "DSPL: Removed " + self.posename)
|
self.report({'INFO'}, "YAPL: Removed " + self.posename)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -163,8 +163,8 @@ class DSPL_OT_RemovePose(bpy.types.Operator):
|
|||||||
# Operator to rename the current pose
|
# Operator to rename the current pose
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_RenamePose(bpy.types.Operator):
|
class YAPL_OT_RenamePose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.rename_pose"
|
bl_idname = "yapl.rename_pose"
|
||||||
bl_label = "Rename Pose"
|
bl_label = "Rename Pose"
|
||||||
bl_description = "Rename Pose"
|
bl_description = "Rename Pose"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -186,7 +186,7 @@ class DSPL_OT_RenamePose(bpy.types.Operator):
|
|||||||
target_marker.name = self.pose_new_name
|
target_marker.name = self.pose_new_name
|
||||||
context.area.tag_redraw()
|
context.area.tag_redraw()
|
||||||
|
|
||||||
self.report({'INFO'}, "DSPL: Renamed " + self.posename + " to " + self.pose_new_name + " on frame " + str(active_marker.frame))
|
self.report({'INFO'}, "YAPL: Renamed " + self.posename + " to " + self.pose_new_name + " on frame " + str(active_marker.frame))
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
else:
|
else:
|
||||||
@ -201,8 +201,8 @@ class DSPL_OT_RenamePose(bpy.types.Operator):
|
|||||||
# Operator to reorder pose markers
|
# Operator to reorder pose markers
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_MovePose(bpy.types.Operator):
|
class YAPL_OT_MovePose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.move_pose"
|
bl_idname = "yapl.move_pose"
|
||||||
bl_label = "Move Pose"
|
bl_label = "Move Pose"
|
||||||
bl_description = "Move pose"
|
bl_description = "Move pose"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -251,8 +251,8 @@ class DSPL_OT_MovePose(bpy.types.Operator):
|
|||||||
# Operator to apply a pose from active marker
|
# Operator to apply a pose from active marker
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_ApplyPose(bpy.types.Operator):
|
class YAPL_OT_ApplyPose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.apply_pose"
|
bl_idname = "yapl.apply_pose"
|
||||||
bl_label = "Apply Pose"
|
bl_label = "Apply Pose"
|
||||||
bl_description = "Apply Pose (Ctrl+Click to select, Shift+Click to rename, Alt+Click to remove)"
|
bl_description = "Apply Pose (Ctrl+Click to select, Shift+Click to rename, Alt+Click to remove)"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -277,7 +277,7 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
|
|||||||
|
|
||||||
set_bones_from_keyframes(context, arm_object, active_marker)
|
set_bones_from_keyframes(context, arm_object, active_marker)
|
||||||
|
|
||||||
self.report({'INFO'}, "DSPL: Applied " + active_posename)
|
self.report({'INFO'}, "YAPL: Applied " + active_posename)
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
@ -289,11 +289,11 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
|
|||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
elif event.alt:
|
elif event.alt:
|
||||||
# Remove
|
# Remove
|
||||||
bpy.ops.dspl.remove_pose(posename = self.posename)
|
bpy.ops.yapl.remove_pose(posename = self.posename)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
elif event.shift:
|
elif event.shift:
|
||||||
# Rename
|
# Rename
|
||||||
bpy.ops.dspl.rename_pose('INVOKE_DEFAULT', posename = self.posename)
|
bpy.ops.yapl.rename_pose('INVOKE_DEFAULT', posename = self.posename)
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
else:
|
else:
|
||||||
return self.execute(context)
|
return self.execute(context)
|
||||||
@ -302,8 +302,8 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
|
|||||||
# Operator to preview up and down pose list
|
# Operator to preview up and down pose list
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_BrowsePoses(bpy.types.Operator):
|
class YAPL_OT_BrowsePoses(bpy.types.Operator):
|
||||||
bl_idname = "dspl.browse_poses"
|
bl_idname = "yapl.browse_poses"
|
||||||
bl_label = "Browse Poses"
|
bl_label = "Browse Poses"
|
||||||
bl_description = "Browse Poses"
|
bl_description = "Browse Poses"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -330,13 +330,13 @@ class DSPL_OT_BrowsePoses(bpy.types.Operator):
|
|||||||
self.pose_library.pose_markers.active_index = len(self.pose_library.pose_markers) - 1
|
self.pose_library.pose_markers.active_index = len(self.pose_library.pose_markers) - 1
|
||||||
else:
|
else:
|
||||||
self.pose_library.pose_markers.active_index = self.pose_library.pose_markers.active_index - 1
|
self.pose_library.pose_markers.active_index = self.pose_library.pose_markers.active_index - 1
|
||||||
bpy.ops.dspl.apply_pose()
|
bpy.ops.yapl.apply_pose()
|
||||||
elif event.type in {'RIGHT_ARROW', 'DOWN_ARROW'}:
|
elif event.type in {'RIGHT_ARROW', 'DOWN_ARROW'}:
|
||||||
if self.pose_library.pose_markers.active_index + 1 >= len(self.pose_library.pose_markers):
|
if self.pose_library.pose_markers.active_index + 1 >= len(self.pose_library.pose_markers):
|
||||||
self.pose_library.pose_markers.active_index = 0
|
self.pose_library.pose_markers.active_index = 0
|
||||||
else:
|
else:
|
||||||
self.pose_library.pose_markers.active_index = self.pose_library.pose_markers.active_index + 1
|
self.pose_library.pose_markers.active_index = self.pose_library.pose_markers.active_index + 1
|
||||||
bpy.ops.dspl.apply_pose()
|
bpy.ops.yapl.apply_pose()
|
||||||
|
|
||||||
if event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER'}:
|
if event.type in {'LEFTMOUSE', 'RET', 'NUMPAD_ENTER'}:
|
||||||
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
|
bpy.types.SpaceView3D.draw_handler_remove(self._handle, 'WINDOW')
|
||||||
@ -357,15 +357,15 @@ class DSPL_OT_BrowsePoses(bpy.types.Operator):
|
|||||||
self.arm_object, self.pose_library = get_armature_data(context)
|
self.arm_object, self.pose_library = get_armature_data(context)
|
||||||
|
|
||||||
if self.pose_library is None:
|
if self.pose_library is None:
|
||||||
self.report({'WARNING'}, "DSPL: Pose Library not active")
|
self.report({'WARNING'}, "YAPL: Pose Library not active")
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
self.arm_object.pose.backup_create(self.pose_library)
|
self.arm_object.pose.backup_create(self.pose_library)
|
||||||
self.backup_index = self.pose_library.pose_markers.active_index
|
self.backup_index = self.pose_library.pose_markers.active_index
|
||||||
bpy.ops.dspl.apply_pose()
|
bpy.ops.yapl.apply_pose()
|
||||||
|
|
||||||
if context.area.type == 'VIEW_3D':
|
if context.area.type == 'VIEW_3D':
|
||||||
self.report({'INFO'}, "DSPL: Browsing Poses")
|
self.report({'INFO'}, "YAPL: Browsing Poses")
|
||||||
args = (self, context)
|
args = (self, context)
|
||||||
self._handle = bpy.types.SpaceView3D.draw_handler_add(self.draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
|
self._handle = bpy.types.SpaceView3D.draw_handler_add(self.draw_callback_px, args, 'WINDOW', 'POST_PIXEL')
|
||||||
context.window_manager.modal_handler_add(self)
|
context.window_manager.modal_handler_add(self)
|
||||||
@ -376,8 +376,8 @@ class DSPL_OT_BrowsePoses(bpy.types.Operator):
|
|||||||
# Operator to unlink a pose library and mark for removal
|
# Operator to unlink a pose library and mark for removal
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_UnlinkPoseLibrary(bpy.types.Operator):
|
class YAPL_OT_UnlinkPoseLibrary(bpy.types.Operator):
|
||||||
bl_idname = "dspl.unlink_pose_library"
|
bl_idname = "yapl.unlink_pose_library"
|
||||||
bl_label = "Unlink Pose Library"
|
bl_label = "Unlink Pose Library"
|
||||||
bl_description = "Unlink Pose Library"
|
bl_description = "Unlink Pose Library"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -399,8 +399,8 @@ class DSPL_OT_UnlinkPoseLibrary(bpy.types.Operator):
|
|||||||
# Operator to protect orphaned legacy pose libraries
|
# Operator to protect orphaned legacy pose libraries
|
||||||
|
|
||||||
|
|
||||||
class DSPL_OT_ProtectOrphanPoseLibrary(bpy.types.Operator):
|
class YAPL_OT_ProtectOrphanPoseLibrary(bpy.types.Operator):
|
||||||
bl_idname = "dspl.protect_orphan_pose_library"
|
bl_idname = "yapl.protect_orphan_pose_library"
|
||||||
bl_label = "Protect Orphaned Pose Libraries"
|
bl_label = "Protect Orphaned Pose Libraries"
|
||||||
bl_description = "Protect Orphaned Pose Libraries"
|
bl_description = "Protect Orphaned Pose Libraries"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
@ -436,23 +436,23 @@ class DSPL_OT_ProtectOrphanPoseLibrary(bpy.types.Operator):
|
|||||||
if orphaned_act:
|
if orphaned_act:
|
||||||
for act in orphaned_act:
|
for act in orphaned_act:
|
||||||
if "_loc" in act.name or "PoseLib" in act.name:
|
if "_loc" in act.name or "PoseLib" in act.name:
|
||||||
self.report({'INFO'}, "DSPL: Protecting orphaned action: " + act.name)
|
self.report({'INFO'}, "YAPL: Protecting orphaned action: " + act.name)
|
||||||
act.use_fake_user = True
|
act.use_fake_user = True
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
||||||
classes = (
|
classes = (
|
||||||
DSPL_OT_CreatePoseLibrary,
|
YAPL_OT_CreatePoseLibrary,
|
||||||
DSPL_OT_ConvertPoseLibrary,
|
YAPL_OT_ConvertPoseLibrary,
|
||||||
DSPL_OT_AddPose,
|
YAPL_OT_AddPose,
|
||||||
DSPL_OT_RemovePose,
|
YAPL_OT_RemovePose,
|
||||||
DSPL_OT_RenamePose,
|
YAPL_OT_RenamePose,
|
||||||
DSPL_OT_MovePose,
|
YAPL_OT_MovePose,
|
||||||
DSPL_OT_ApplyPose,
|
YAPL_OT_ApplyPose,
|
||||||
DSPL_OT_BrowsePoses,
|
YAPL_OT_BrowsePoses,
|
||||||
DSPL_OT_UnlinkPoseLibrary,
|
YAPL_OT_UnlinkPoseLibrary,
|
||||||
DSPL_OT_ProtectOrphanPoseLibrary
|
YAPL_OT_ProtectOrphanPoseLibrary
|
||||||
)
|
)
|
||||||
|
|
||||||
register, unregister = bpy.utils.register_classes_factory(classes)
|
register, unregister = bpy.utils.register_classes_factory(classes)
|
||||||
|
Reference in New Issue
Block a user