glTF exporter: Create output directory if not exists

This should happen mainly for Collection Exporter or using api
This commit is contained in:
Julien Duroure 2025-02-01 18:55:46 +01:00
parent 3d2f45b408
commit cccd45e32a
2 changed files with 9 additions and 1 deletions

View File

@ -5,7 +5,7 @@
bl_info = {
'name': 'glTF 2.0 format',
'author': 'Julien Duroure, Scurest, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors',
"version": (4, 4, 37),
"version": (4, 4, 38),
'blender': (4, 4, 0),
'location': 'File > Import-Export',
'description': 'Import-Export as glTF 2.0',

View File

@ -53,6 +53,14 @@ def save(context, export_settings):
def __export(export_settings):
exporter = GlTF2Exporter(export_settings)
__gather_gltf(exporter, export_settings)
# If the directory does not exist, create it
if not os.path.isdir(export_settings['gltf_filedirectory']):
os.makedirs(export_settings['gltf_filedirectory'])
if export_settings['gltf_format'] == "GLTF_SEPARATE" \
and not os.path.isdir(export_settings['gltf_texturedirectory']):
os.makedirs(export_settings['gltf_texturedirectory'])
buffer = __create_buffer(exporter, export_settings)
exporter.finalize_images()