1 Commits

Author SHA1 Message Date
592a9602d8 Use Object.pose_library instead of Object.dspl.pose_library 2024-12-28 04:50:52 -06:00
4 changed files with 40 additions and 37 deletions

View File

@ -22,36 +22,23 @@ if _need_reload:
operators = importlib.reload(operators) operators = importlib.reload(operators)
class dsplObj(bpy.types.PropertyGroup):
pose_library: bpy.props.PointerProperty(
name="Active Pose Library", description="",
override={'LIBRARY_OVERRIDABLE'}, type=bpy.types.Action)
# update = common.poselib_update)
# , update = anim_layers.layer_name_update
class dsplSettings(bpy.types.PropertyGroup): class dsplSettings(bpy.types.PropertyGroup):
new_menu: bpy.props.BoolProperty( new_menu: bpy.props.BoolProperty(
name="New Menu", description="Toggle New Menu", default=False) name="New Menu", description="Toggle New Menu", default=False)
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 = (dsplObj, dsplSettings) classes = dsplSettings
def register(): def register():
from bpy.utils import register_class from bpy.utils import register_class
for cls in classes: register_class(dsplSettings)
register_class(cls)
# bpy.types.Armature.pose_library = bpy.props.PointerProperty( bpy.types.Object.pose_library = bpy.props.PointerProperty(
# type=dsplObj, override={'LIBRARY_OVERRIDABLE'}) name="Active Pose Library", description="",
type=bpy.types.Action, override={'LIBRARY_OVERRIDABLE'})
# bpy.types.Object.pose_library = bpy.props.PointerProperty(
# type=bpy.types.Action, options={'LIBRARY_EDITABLE'}, override={'LIBRARY_OVERRIDABLE'})
bpy.types.Object.dspl = bpy.props.PointerProperty(
type=dsplObj, override={'LIBRARY_OVERRIDABLE'})
bpy.types.Scene.dsplSettings = bpy.props.PointerProperty( bpy.types.Scene.dsplSettings = bpy.props.PointerProperty(
type=dsplSettings, override={'LIBRARY_OVERRIDABLE'}) type=dsplSettings, override={'LIBRARY_OVERRIDABLE'})
@ -59,12 +46,10 @@ def register():
operators.register() operators.register()
keymaps.register() keymaps.register()
def unregister() -> None: def unregister():
from bpy.utils import unregister_class from bpy.utils import unregister_class
for cls in classes: unregister_class(dsplSettings)
unregister_class(cls)
del bpy.types.Object.dspl
del bpy.types.Scene.dsplSettings del bpy.types.Scene.dsplSettings
keymaps.unregister() keymaps.unregister()

View File

@ -14,18 +14,27 @@ def getArmatureObject(context):
def getLegacyPoseLibrary(context): def getLegacyPoseLibrary(context):
arm = getArmatureObject(context) try:
return getattr(arm, "pose_library", None) arm = getArmatureObject(context)
return getattr(arm, "pose_library", None)
except:
pass
def getArmatureAction(context): def getArmatureAction(context):
arm = getArmatureObject(context) try:
return getattr(arm.animation_data, "action", None) arm = getArmatureObject(context)
return getattr(arm.animation_data, "action", None)
except:
pass
def getDsplAction(context): def getDsplAction(context):
arm = getArmatureObject(context) try:
return getattr(arm.dspl, "pose_library", None) arm = getArmatureObject(context)
return getattr(arm.dspl, "pose_library", None)
except:
pass
def getPoseLib(context): def getPoseLib(context):

14
gui.py
View File

@ -31,12 +31,18 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
# Attach or create pose library # Attach or create pose library
pose_library_dspl = getDsplAction(context) pose_library_dspl = getDsplAction(context)
pose_library_action = getArmatureAction(context) pose_library_action = getArmatureAction(context)
pose_library_legacy = getLegacyPoseLibrary(context)
if pose_library_dspl or pose_library_action: if pose_library_dspl or pose_library_action or pose_library_legacy:
if pose_library_dspl and not pose_library_action: if pose_library_dspl and not pose_library_action:
active_pose_library = pose_library_dspl active_pose_library = pose_library_dspl
armature_layout.template_ID( armature_layout.template_ID(
arm_object.dspl, "pose_library", new="dspl.create_pose_library", unlink="dspl.unlink_pose_library") arm_object, "pose_library", new="dspl.create_pose_library", unlink="dspl.unlink_pose_library")
elif pose_library_legacy and not pose_library_dspl:
active_pose_library = pose_library_legacy
armature_layout.template_ID(
arm_object, "pose_library", new="dspl.create_pose_library", unlink="dspl.unlink_pose_library")
elif pose_library_action and not pose_library_dspl: elif pose_library_action and not pose_library_dspl:
active_pose_library = pose_library_action active_pose_library = pose_library_action
@ -51,7 +57,7 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
elif pose_library_action and pose_library_dspl: elif pose_library_action and pose_library_dspl:
armature_layout.template_ID( armature_layout.template_ID(
arm_object.dspl, "pose_library", new="dspl.create_pose_library") arm_object, "pose_library", new="dspl.create_pose_library")
armature_layout.label(text="Double pose configuration!!") armature_layout.label(text="Double pose configuration!!")
armature_layout.label(text="You should not proceed") armature_layout.label(text="You should not proceed")
armature_layout.operator( armature_layout.operator(
@ -141,7 +147,7 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
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.dspl, "pose_library", new="dspl.create_pose_library") arm_object, "pose_library", new="dspl.create_pose_library")
else: else:
armature_layout.label(text="No armature or parent selected") armature_layout.label(text="No armature or parent selected")

View File

@ -14,9 +14,9 @@ class DSPL_OT_CreatePoseLibrary(bpy.types.Operator):
def execute(self, context): def execute(self, context):
arm_object = getArmatureObject(context) arm_object = getArmatureObject(context)
arm_object.dspl.pose_library = bpy.data.actions.new( arm_object.pose_library = bpy.data.actions.new(
name=arm_object.name + "_PoseLib") name=arm_object.name + "_PoseLib")
arm_object.dspl.pose_library.use_fake_user = True arm_object.pose_library.use_fake_user = True
return {'FINISHED'} return {'FINISHED'}
@ -32,7 +32,7 @@ class DSPL_OT_ConvertPoseLibrary(bpy.types.Operator):
def execute(self, context): def execute(self, context):
arm_object = getArmatureObject(context) arm_object = getArmatureObject(context)
arm_object.dspl.pose_library = arm_object.animation_data.action arm_object.pose_library = arm_object.animation_data.action
arm_object.animation_data.action = None arm_object.animation_data.action = None
return {'FINISHED'} return {'FINISHED'}
@ -399,8 +399,11 @@ class DSPL_OT_UnlinkPoseLibrary(bpy.types.Operator):
arm_object = getArmatureObject(context) arm_object = getArmatureObject(context)
pose_library = getPoseLib(context) pose_library = getPoseLib(context)
arm_object.dspl.pose_library.name = "del_" + arm_object.dspl.pose_library.name try:
arm_object.dspl.pose_library = None arm_object.pose_library.name = "del_" + arm_object.pose_library.name
except:
pass
arm_object.pose_library = None
return {'FINISHED'} return {'FINISHED'}