Closed JoshQuake closed 2 months ago
Are these not doing exactly that? 🤔
Added clarification:
@Joshimals ah, my mistake then. Any error in the patched code will fail to restore the previous state.
A temporary context can be used to handle temporary overrides that survive exceptions.
Suggest to split up export and the override into two functions to avoid the override logic being mixed in with setup/teardown. You may want to use contextlib.contextmanager which makes this convenient.
I think doing a
try:
self = type(
'Send2UeExportFBX',
(object,),
{'report': report_error}
)
export_fbx_bin.save(self, bpy.context, **keywords)
finally:
export_fbx_bin.fbx_animations_do = original_fbx_animations_do
export_fbx_bin.fbx_data_armature_elements = original_fbx_data_armature_elements
export_fbx_bin.fbx_data_object_elements = original_fbx_data_object_elements
export_fbx_bin.fbx_data_bindpose_element = original_fbx_data_bindpose_element
Would achieve this and ensure it is always restored
Required change for Extensions compliance: https://extensions.blender.org/approval-queue/send2ue/#activity-2139