fix: Loop through fcurves and get selected only
This is potentially more expensive, but is more convenient to the user when they may potentially have more than one fcurve selected in the graph editor.
This commit is contained in:
parent
8380dbbf5c
commit
706525fde1
43
__init__.py
43
__init__.py
|
@ -76,12 +76,14 @@ class FCurveHandleCopyValue(bpy.types.Operator):
|
||||||
fcurves = context.selected_visible_fcurves
|
fcurves = context.selected_visible_fcurves
|
||||||
G.selected_keys = []
|
G.selected_keys = []
|
||||||
|
|
||||||
if (len(fcurves) > 1):
|
for fcurve in fcurves:
|
||||||
self.report({"WARNING"}, "Please only select one curve when copying an ease.")
|
for key in fcurve.keyframe_points:
|
||||||
|
if key.select_control_point:
|
||||||
|
G.selected_keys.append(key)
|
||||||
|
if (len(G.selected_keys) > 2):
|
||||||
|
self.report({"WARNING"}, "Please select exactly two keyframes when copying an ease.")
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
|
||||||
G.selected_keys = list(filter(lambda x: x.select_control_point, fcurves[0].keyframe_points))
|
|
||||||
|
|
||||||
if (len(G.selected_keys) != 2):
|
if (len(G.selected_keys) != 2):
|
||||||
self.report({"WARNING"}, "Please select exactly two keyframes when copying an ease.")
|
self.report({"WARNING"}, "Please select exactly two keyframes when copying an ease.")
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
|
@ -99,30 +101,35 @@ class FCurveHandlePasteValue(bpy.types.Operator):
|
||||||
if (context.selected_visible_fcurves):
|
if (context.selected_visible_fcurves):
|
||||||
fcurves = context.selected_visible_fcurves
|
fcurves = context.selected_visible_fcurves
|
||||||
|
|
||||||
|
selected_keys = {}
|
||||||
|
|
||||||
for fcurve in fcurves:
|
for fcurve in fcurves:
|
||||||
keys = fcurve.keyframe_points
|
keys = fcurve.keyframe_points
|
||||||
selected_keys = []
|
|
||||||
for i in range(0, len(keys)):
|
for i in range(0, len(keys)):
|
||||||
if (keys[i].select_control_point):
|
if (keys[i].select_control_point):
|
||||||
selected_keys.append(i)
|
if fcurve not in selected_keys:
|
||||||
|
selected_keys[fcurve] = []
|
||||||
|
selected_keys[fcurve].append(keys[i])
|
||||||
|
|
||||||
if (len(selected_keys) == 0):
|
for fcurve, keys in selected_keys.items():
|
||||||
|
if (len(keys) == 0):
|
||||||
self.report({"WARNING"}, "Please select some keyframes to paste an ease to.")
|
self.report({"WARNING"}, "Please select some keyframes to paste an ease to.")
|
||||||
return {'CANCELLED'}
|
return {'CANCELLED'}
|
||||||
if (len(selected_keys) == 1):
|
if (len(keys) == 1):
|
||||||
# TODO: Implement logic for this soon
|
# TODO: Implement logic for this soon
|
||||||
pass
|
pass
|
||||||
else:
|
else:
|
||||||
selected_keys.pop() # TODO: Related to above, implement soon
|
keys.pop() # TODO: Related to above, implement soon
|
||||||
for i in selected_keys:
|
for i, _ in enumerate(keys):
|
||||||
if (i < len(keys) - 1):
|
f_keys = fcurve.keyframe_points
|
||||||
new_handles = generate_new_handles(keys[i], keys[i + 1])
|
if (i < len(f_keys) - 1):
|
||||||
keys[i].interpolation = 'BEZIER'
|
new_handles = generate_new_handles(f_keys[i], f_keys[i + 1])
|
||||||
keys[i + 1].interpolation = 'BEZIER'
|
f_keys[i].interpolation = 'BEZIER'
|
||||||
keys[i].handle_right_type = 'FREE'
|
f_keys[i + 1].interpolation = 'BEZIER'
|
||||||
keys[i + 1].handle_left_type = 'FREE'
|
f_keys[i].handle_right_type = 'FREE'
|
||||||
keys[i].handle_right = new_handles[0]
|
f_keys[i + 1].handle_left_type = 'FREE'
|
||||||
keys[i + 1].handle_left = new_handles[1]
|
f_keys[i].handle_right = new_handles[0]
|
||||||
|
f_keys[i + 1].handle_left = new_handles[1]
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user