glTF-Blender-IO icon indicating copy to clipboard operation
glTF-Blender-IO copied to clipboard

Exporter Callback to return glb buffer and json as well as disable output file writing

Open OptimisticMonkey opened this issue 1 year ago • 2 comments

Thank you so much for making glTF-Blender-IO - it is awesome!!!

I am writing a "geometry clipboard" utility for Blender, Unreal, Houdini, etc that uses a glb memory buffer.

For exporting from Blender, I am using glTF-Blender-IO. But I need to disable writing the output to a file, and instead just return the buffer and json of the glb to a callback.

I am just uncertain how to pass a callback function to the exporter.

My operator is calling: bpy.ops.export_scene.gltf(filepath=export_path, export_format='GLB', use_selection=True, use_memory_buffer = True)

(use_memory_buffer is a bool setting I added for testing) I was hoping to pass the exporter an additional callback method instead of that bool.

In gltf2_blender_export.py source, save(context, export_settings):

I have located the data I want: json, buffer = __export(export_settings)

and also the file write I want to disable: __write_file(json, buffer, export_settings)

Can I add a PointerProperty setting and use it to pass a callback to the exporter?

Thanks for any help/advice - I am still learning python and blender

OptimisticMonkey avatar Apr 13 '23 14:04 OptimisticMonkey