I am making the call to
bpy.ops.export_scene.gltf(filepath=output_file, use_selection=True, export_format='GLTF_SEPARATE')
I tried the workaround here Script to export gltf fails with 'Context' object has no attribute 'active_object'
AttributeError: 'Context' object has no attribute 'active_object'
Passing the context to the gltf function looks to be deprecated and I don't see how to override the context using temp_override.
I assume I am not setting up the context correctly as I tried to export as fbx and also got an exception.
Anyone have any suggestions?
EDIT: Added a minimalistic script:
Clear the scene
#bpy.ops.wm.read_homefile(use_empty=True) #bpy.ops.wm.read_factory_settings(use_empty=True)
Load the GLTF file into an empty scene
bpy.ops.import_scene.gltf(filepath=GLTF_PATH)
out_path = utils.create_output_folder("xxxxx")
OUTPUT_FILE = out_path + "out.gltf" bpy.ops.export_scene.gltf(filepath=OUTPUT_FILE, use_selection=True, export_format='GLTF_SEPARATE')
If I include either of the lines to clear the scene I get the error. Wondering if there is a more correct way to clear Blender down to a state where it has no loaded data.