diff --git a/io_scene_gltf2/__init__.py b/io_scene_gltf2/__init__.py index 40e401586a6b4db29edad95487d7f36ff3d5faa9..e60bf8b8ef5109ae4668cf021abc3c50e67b1d22 100755 --- a/io_scene_gltf2/__init__.py +++ b/io_scene_gltf2/__init__.py @@ -15,7 +15,7 @@ bl_info = { 'name': 'glTF 2.0 format', 'author': 'Julien Duroure, Norbert Nopper, Urs Hanselmann, Moritz Becher, Benjamin Schmithüsen, Jim Eckerlein, and many external contributors', - "version": (1, 2, 41), + "version": (1, 2, 42), 'blender': (2, 82, 7), 'location': 'File > Import-Export', 'description': 'Import-Export as glTF 2.0', diff --git a/io_scene_gltf2/blender/exp/gltf2_blender_export.py b/io_scene_gltf2/blender/exp/gltf2_blender_export.py index 0e415e7abfdc0f21855e2da3dec3e6c36b3cf92a..6d9ab8bbef703d03bdbf3ac53732bc7670faaf45 100755 --- a/io_scene_gltf2/blender/exp/gltf2_blender_export.py +++ b/io_scene_gltf2/blender/exp/gltf2_blender_export.py @@ -24,6 +24,7 @@ from io_scene_gltf2.blender.exp.gltf2_blender_gltf2_exporter import GlTF2Exporte from io_scene_gltf2.io.com.gltf2_io_debug import print_console, print_newline from io_scene_gltf2.io.exp import gltf2_io_export from io_scene_gltf2.io.exp import gltf2_io_draco_compression_extension +from io_scene_gltf2.io.exp.gltf2_io_user_extensions import export_user_extensions def save(context, export_settings): @@ -61,6 +62,10 @@ def __export(export_settings): def __gather_gltf(exporter, export_settings): active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings) + plan = {'active_scene_idx': active_scene_idx, 'scenes': scenes, 'animations': animations} + export_user_extensions('gather_gltf_hook', export_settings, plan) + active_scene_idx, scenes, animations = plan['active_scene_idx'], plan['scenes'], plan['animations'] + if export_settings['gltf_draco_mesh_compression']: gltf2_io_draco_compression_extension.compress_scene_primitives(scenes, export_settings) exporter.add_draco_extension() diff --git a/io_scene_gltf2/io/exp/gltf2_io_user_extensions.py b/io_scene_gltf2/io/exp/gltf2_io_user_extensions.py index 424713c3e4849a9401aa41c1a756efb7213e1169..a149673f683e122bd28b7cb6c648b6482a55da42 100644 --- a/io_scene_gltf2/io/exp/gltf2_io_user_extensions.py +++ b/io_scene_gltf2/io/exp/gltf2_io_user_extensions.py @@ -12,11 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -def export_user_extensions(hook_name, export_settings, gltf2_object, *args): - if gltf2_object.extensions is None: - gltf2_object.extensions = {} +def export_user_extensions(hook_name, export_settings, *args): + if args and hasattr(args[0], "extensions"): + if args[0].extensions is None: + args[0].extensions = {} for extension in export_settings['gltf_user_extensions']: hook = getattr(extension, hook_name, None) if hook is not None: - hook(gltf2_object, *args, export_settings) + try: + hook(*args, export_settings) + except Exception as e: + print(hook_name, "fails on", extension) + print(str(e))