From f7290e6808f9f19dda2a1325fdc8381608f6a6f1 Mon Sep 17 00:00:00 2001 From: Colin Basnett Date: Tue, 1 Nov 2022 11:30:13 -0700 Subject: [PATCH] The scene's frame and selected object's active action is now restored after PSA export --- io_scene_psk_psa/psa/builder.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/io_scene_psk_psa/psa/builder.py b/io_scene_psk_psa/psa/builder.py index d2f50a5..f219df9 100644 --- a/io_scene_psk_psa/psa/builder.py +++ b/io_scene_psk_psa/psa/builder.py @@ -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 = 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. # We actually alter the timeline frame and simply record the resultant pose bone matrices. 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 + # Restore the previous action & frame. + animation_data.action = saved_action + context.scene.frame_set(saved_frame_current) + return psa