Use Object.pose_library instead of Object.dspl.pose_library
This commit is contained in:
29
__init__.py
29
__init__.py
@ -22,36 +22,23 @@ if _need_reload:
|
||||
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):
|
||||
new_menu: bpy.props.BoolProperty(
|
||||
name="New Menu", description="Toggle New Menu", default=False)
|
||||
edit_mode: bpy.props.BoolProperty(
|
||||
name="Edit Mode", description="Toggle Edit Mode", default=False)
|
||||
|
||||
classes = (dsplObj, dsplSettings)
|
||||
classes = dsplSettings
|
||||
|
||||
|
||||
def register():
|
||||
from bpy.utils import register_class
|
||||
for cls in classes:
|
||||
register_class(cls)
|
||||
register_class(dsplSettings)
|
||||
|
||||
# bpy.types.Armature.pose_library = bpy.props.PointerProperty(
|
||||
# type=dsplObj, override={'LIBRARY_OVERRIDABLE'})
|
||||
bpy.types.Object.pose_library = bpy.props.PointerProperty(
|
||||
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(
|
||||
type=dsplSettings, override={'LIBRARY_OVERRIDABLE'})
|
||||
|
||||
@ -59,12 +46,10 @@ def register():
|
||||
operators.register()
|
||||
keymaps.register()
|
||||
|
||||
def unregister() -> None:
|
||||
def unregister():
|
||||
from bpy.utils import unregister_class
|
||||
for cls in classes:
|
||||
unregister_class(cls)
|
||||
unregister_class(dsplSettings)
|
||||
|
||||
del bpy.types.Object.dspl
|
||||
del bpy.types.Scene.dsplSettings
|
||||
|
||||
keymaps.unregister()
|
||||
|
21
common.py
21
common.py
@ -14,18 +14,27 @@ def getArmatureObject(context):
|
||||
|
||||
|
||||
def getLegacyPoseLibrary(context):
|
||||
arm = getArmatureObject(context)
|
||||
return getattr(arm, "pose_library", None)
|
||||
try:
|
||||
arm = getArmatureObject(context)
|
||||
return getattr(arm, "pose_library", None)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def getArmatureAction(context):
|
||||
arm = getArmatureObject(context)
|
||||
return getattr(arm.animation_data, "action", None)
|
||||
try:
|
||||
arm = getArmatureObject(context)
|
||||
return getattr(arm.animation_data, "action", None)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def getDsplAction(context):
|
||||
arm = getArmatureObject(context)
|
||||
return getattr(arm.dspl, "pose_library", None)
|
||||
try:
|
||||
arm = getArmatureObject(context)
|
||||
return getattr(arm.dspl, "pose_library", None)
|
||||
except:
|
||||
pass
|
||||
|
||||
|
||||
def getPoseLib(context):
|
||||
|
14
gui.py
14
gui.py
@ -31,12 +31,18 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
# Attach or create pose library
|
||||
pose_library_dspl = getDsplAction(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:
|
||||
active_pose_library = pose_library_dspl
|
||||
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:
|
||||
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:
|
||||
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="You should not proceed")
|
||||
armature_layout.operator(
|
||||
@ -141,7 +147,7 @@ class DATA_PT_DSPLPanel(bpy.types.Panel):
|
||||
armature_layout.label(
|
||||
text="No Action or Pose Library detected")
|
||||
armature_layout.template_ID(
|
||||
arm_object.dspl, "pose_library", new="dspl.create_pose_library")
|
||||
arm_object, "pose_library", new="dspl.create_pose_library")
|
||||
|
||||
else:
|
||||
armature_layout.label(text="No armature or parent selected")
|
||||
|
15
operators.py
15
operators.py
@ -14,9 +14,9 @@ class DSPL_OT_CreatePoseLibrary(bpy.types.Operator):
|
||||
|
||||
def execute(self, 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")
|
||||
arm_object.dspl.pose_library.use_fake_user = True
|
||||
arm_object.pose_library.use_fake_user = True
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
@ -32,7 +32,7 @@ class DSPL_OT_ConvertPoseLibrary(bpy.types.Operator):
|
||||
|
||||
def execute(self, 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
|
||||
|
||||
return {'FINISHED'}
|
||||
@ -399,8 +399,13 @@ class DSPL_OT_UnlinkPoseLibrary(bpy.types.Operator):
|
||||
arm_object = getArmatureObject(context)
|
||||
pose_library = getPoseLib(context)
|
||||
|
||||
arm_object.dspl.pose_library.name = "del_" + arm_object.dspl.pose_library.name
|
||||
arm_object.dspl.pose_library = None
|
||||
try:
|
||||
arm_object.pose_library.use_fake_user = False
|
||||
# if not arm_object.pose_library.name.startswith("del_"):
|
||||
# arm_object.pose_library.name = "del_{}".format(arm_object.pose_library.name)
|
||||
except:
|
||||
pass
|
||||
arm_object.pose_library = None
|
||||
|
||||
return {'FINISHED'}
|
||||
|
||||
|
Reference in New Issue
Block a user