Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Calling export in RenderEngine does not work #1943

Open
betstick opened this issue Jun 23, 2023 · 4 comments
Open

Calling export in RenderEngine does not work #1943

betstick opened this issue Jun 23, 2023 · 4 comments
Labels
question Further information is requested

Comments

@betstick
Copy link

Describe the bug
When trying to use the export within a bpy RenderEngine render function results in a context error in the console and the export does not occur.

To Reproduce
Steps to reproduce the behavior:
gltf_error_addon.zip
Copy the attached code directory into the addons folder for Blender to install it
Open Blender via a terminal, enable the Error Engine addon in preferences and select Error from the render engine menu
Hit F12 to render
Check the console logs to see the error messages

Expected behavior
The scene should be exported to the specified files/directories.

Screenshots

23:09:26 | INFO: Draco mesh compression is available, use library at /usr/lib/python3.11/site-packages/libextern_draco.so
Traceback (most recent call last):
  File "/usr/share/blender/3.5/scripts/addons/io_scene_gltf2/__init__.py", line 718, in execute
    return gltf2_blender_export.save(context, export_settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/blender/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 21, in save
    if bpy.context.active_object is not None:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Context' object has no attribute 'active_object'
Error: Python: Traceback (most recent call last):
  File "/usr/share/blender/3.5/scripts/addons/io_scene_gltf2/__init__.py", line 718, in execute
    return gltf2_blender_export.save(context, export_settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/blender/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 21, in save
    if bpy.context.active_object is not None:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Context' object has no attribute 'active_object'
Location: /usr/share/blender/3.5/scripts/modules/bpy/ops.py:113
Traceback (most recent call last):
  File "/home/username/.config/blender/3.5/scripts/addons/engine_exporter/engine/engine.py", line 27, in render
    bpy.ops.export_scene.gltf(
  File "/usr/share/blender/3.5/scripts/modules/bpy/ops.py", line 113, in __call__
    ret = _op_call(self.idname_py(), None, kw)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeError: Error: Python: Traceback (most recent call last):
  File "/usr/share/blender/3.5/scripts/addons/io_scene_gltf2/__init__.py", line 718, in execute
    return gltf2_blender_export.save(context, export_settings)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/share/blender/3.5/scripts/addons/io_scene_gltf2/blender/exp/gltf2_blender_export.py", line 21, in save
    if bpy.context.active_object is not None:
       ^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'Context' object has no attribute 'active_object'
Location: /usr/share/blender/3.5/scripts/modules/bpy/ops.py:113

Version

  • OS: Linux 6.3.8
  • Blender Version 3.5.1
@julienduroure
Copy link
Collaborator

Hello,
I can confirm, but not sure to understand why you are trying to use a render engine to export files.
What is your use case? Why not creating a custom operator to export your file?

Currently, export uses various attributes that are not available in rendering context.

@julienduroure julienduroure added the question Further information is requested label Jun 23, 2023
@betstick
Copy link
Author

I've opted to use the GLTF export as it is robust, compatible with multiple systems, and fast. I measured the GLTF exporter to be one of the fastest in Blender (with compression turned off). When I hit F12 to render my scene with my custom engine, I need a way to get the finalized mesh data into my engine. My engine can import from just about any pre-existing format, and I'd rather keep it that way as opposed to writing a custom mesh interface just for Blender.

@betstick
Copy link
Author

I've opted to write a Python exporter for the time being. I don't strictly have need of being able to call the exporter from the RenderEngine context anymore. If it doesn't seem like anyone else would need this, I think the issue can be closed.

@victorb
Copy link

victorb commented Aug 22, 2024

What is your use case? Why not creating a custom operator to export your file?

Would the custom operator be able to get the output from a custom renderer into the viewport, the render window and the various preview panes?

If that's not possible, then being able to call the export inside a render context (with RenderEngine) is to allow custom renderers to really be integrated into Blender and work just like Cycles/EEVEE instead of requiring their own panels.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

3 participants