The scene's frame and selected object's active action is now restored after PSA export

This commit is contained in:
Colin Basnett
2022-11-01 11:30:13 -07:00
parent 65d3104ea9
commit f7290e6808

View File

@@ -224,6 +224,10 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa:
export_sequence.name = f'{options.sequence_name_prefix}{export_sequence.name}{options.sequence_name_suffix}' export_sequence.name = f'{options.sequence_name_prefix}{export_sequence.name}{options.sequence_name_suffix}'
export_sequence.name = export_sequence.name.strip() export_sequence.name = export_sequence.name.strip()
# Save the current action and frame so that we can restore the state once we are done.
saved_frame_current = context.scene.frame_current
saved_action = animation_data.action
# Now build the PSA sequences. # Now build the PSA sequences.
# We actually alter the timeline frame and simply record the resultant pose bone matrices. # We actually alter the timeline frame and simply record the resultant pose bone matrices.
frame_start_index = 0 frame_start_index = 0
@@ -284,4 +288,8 @@ def build_psa(context: bpy.types.Context, options: PsaBuildOptions) -> Psa:
psa.sequences[export_sequence.name] = psa_sequence psa.sequences[export_sequence.name] = psa_sequence
# Restore the previous action & frame.
animation_data.action = saved_action
context.scene.frame_set(saved_frame_current)
return psa return psa