Skip to content

Commit

Permalink
feat(gltf_auto_export): added support for exports in edit_mode
Browse files Browse the repository at this point in the history
 * saves mode, switches to object mode for export & resets to original mode
 * solves issues with the gltf_exporter not working with edit mode
  • Loading branch information
kaosat-dev committed Feb 4, 2024
1 parent 09cb347 commit 0ffa3fe
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions tools/gltf_auto_export/generate_and_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ def generate_and_export(addon_prefs, export_settings, gltf_output_path, temp_sce
original_scene = bpy.context.window.scene
# and selected collection
original_collection = bpy.context.view_layer.active_layer_collection
# and mode
original_mode = bpy.context.object.mode if bpy.context.object != None else None
# we change the mode to object mode, otherwise the gltf exporter is not happy
if original_mode != None:
bpy.ops.object.mode_set(mode='OBJECT')
# we set our active scene to be this one : this is needed otherwise the stand-in empties get generated in the wrong scene
bpy.context.window.scene = temp_scene

Expand All @@ -42,3 +47,7 @@ def generate_and_export(addon_prefs, export_settings, gltf_output_path, temp_sce
bpy.context.window.scene = original_scene
# reset active collection
bpy.context.view_layer.active_layer_collection = original_collection
# reset mode
if original_mode != None:
bpy.ops.object.mode_set( mode = original_mode )

0 comments on commit 0ffa3fe

Please sign in to comment.