Compare commits
1 Commits
select-but
...
6b799a4663
Author | SHA1 | Date | |
---|---|---|---|
6b799a4663 |
58
common.py
58
common.py
@ -37,17 +37,6 @@ def searchPoseMarker(context, posename, type):
|
|||||||
pass
|
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):
|
def findFcurve(context, bone_name, transform, index_int):
|
||||||
arm_object, pose_library = getArmatureData(context)
|
arm_object, pose_library = getArmatureData(context)
|
||||||
pose_markers = pose_library.pose_markers
|
pose_markers = pose_library.pose_markers
|
||||||
@ -73,16 +62,6 @@ def createFcurve(context, bone_name, transform, index_int):
|
|||||||
pass
|
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):
|
def createKeyframe(context, bone_name, transform, index_int, new_marker, loc):
|
||||||
arm_object, pose_library = getArmatureData(context)
|
arm_object, pose_library = getArmatureData(context)
|
||||||
pose_markers = pose_library.pose_markers
|
pose_markers = pose_library.pose_markers
|
||||||
@ -105,7 +84,15 @@ def setKeyframesFromBones(context, arm_object, new_marker):
|
|||||||
if bone.bone.select or none_selected == True:
|
if bone.bone.select or none_selected == True:
|
||||||
bone_name = bone.name
|
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 == "XZY":
|
||||||
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "YXZ":
|
||||||
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "YZX":
|
||||||
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "ZXY":
|
||||||
rot_mode = "rotation_euler"
|
rot_mode = "rotation_euler"
|
||||||
elif bone.rotation_mode == "QUATERNION":
|
elif bone.rotation_mode == "QUATERNION":
|
||||||
rot_mode = "rotation_quaternion"
|
rot_mode = "rotation_quaternion"
|
||||||
@ -166,10 +153,15 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
|
|||||||
if bone.bone.select or none_selected == True:
|
if bone.bone.select or none_selected == True:
|
||||||
bone_name = bone.name
|
bone_name = bone.name
|
||||||
|
|
||||||
if findKeyframe(context, bone, active_marker.frame) is None:
|
if bone.rotation_mode == "XYZ":
|
||||||
continue
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "XZY":
|
||||||
if bone.rotation_mode in ("XYZ", "XZY", "YXZ", "YZX", "ZXY", "ZYX"):
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "YXZ":
|
||||||
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "YZX":
|
||||||
|
rot_mode = "rotation_euler"
|
||||||
|
elif bone.rotation_mode == "ZXY":
|
||||||
rot_mode = "rotation_euler"
|
rot_mode = "rotation_euler"
|
||||||
elif bone.rotation_mode == "QUATERNION":
|
elif bone.rotation_mode == "QUATERNION":
|
||||||
rot_mode = "rotation_quaternion"
|
rot_mode = "rotation_quaternion"
|
||||||
@ -194,9 +186,21 @@ def setBonesfromKeyframes(context, arm_object, active_marker):
|
|||||||
scl_z = findFcurve(context, bone_name, "scale", 2) or 1.0
|
scl_z = findFcurve(context, bone_name, "scale", 2) or 1.0
|
||||||
|
|
||||||
bone.location = mathutils.Vector((loc_x, loc_y, loc_z))
|
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(
|
bone.rotation_euler = mathutils.Euler(
|
||||||
(rot_x, rot_y, rot_z))
|
(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":
|
elif rot_mode == "rotation_quaternion":
|
||||||
bone.rotation_quaternion = mathutils.Quaternion(
|
bone.rotation_quaternion = mathutils.Quaternion(
|
||||||
(rot_w, rot_x, rot_y, rot_z))
|
(rot_w, rot_x, rot_y, rot_z))
|
||||||
|
13
operators.py
13
operators.py
@ -254,7 +254,7 @@ class DSPL_OT_MovePose(bpy.types.Operator):
|
|||||||
class DSPL_OT_ApplyPose(bpy.types.Operator):
|
class DSPL_OT_ApplyPose(bpy.types.Operator):
|
||||||
bl_idname = "dspl.apply_pose"
|
bl_idname = "dspl.apply_pose"
|
||||||
bl_label = "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, Shift+Click to rename, Alt+Click to remove)"
|
||||||
bl_options = {'REGISTER', 'UNDO'}
|
bl_options = {'REGISTER', 'UNDO'}
|
||||||
|
|
||||||
posename: bpy.props.StringProperty()
|
posename: bpy.props.StringProperty()
|
||||||
@ -283,16 +283,9 @@ class DSPL_OT_ApplyPose(bpy.types.Operator):
|
|||||||
|
|
||||||
def invoke(self, context, event):
|
def invoke(self, context, event):
|
||||||
if event.ctrl:
|
if event.ctrl:
|
||||||
# Select bones
|
# Select
|
||||||
arm_object, pose_library = getArmatureData(context)
|
arm_object, pose_library = getArmatureData(context)
|
||||||
active_marker = searchPoseMarker(context, posename=self.posename, type="marker")
|
pose_library.pose_markers.active_index = searchPoseMarker(context, posename=self.posename, type="index")
|
||||||
|
|
||||||
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)
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
elif event.alt:
|
elif event.alt:
|
||||||
# Remove
|
# Remove
|
||||||
|
Reference in New Issue
Block a user