mitsuba-renderer / mitsuba-blender

Mitsuba integration add-on for Blender
BSD 3-Clause "New" or "Revised" License
278 stars 36 forks source link

Plugin not usable with bpy #102

Open Oberschnulli opened 5 months ago

Oberschnulli commented 5 months ago

Issue Title (please complete the title by following the instructions and remove this paragraph) I'm able to export my scene from blender to mitsuba via the GUI. But I neet to that 4000 times and want to automate it. Unfortunately the export via python somehow stopped working..

Bug Description cannot export the mitsuba scene via the python terminal in blender ir by using the command line

To Reproduce Steps to reproduce the behavior:

>>> bpy.ops.export_scene.mitsuba(filepath="test.xml")
Scene File: test.xml
Scene Folder: .
Error: Python: Traceback (most recent call last):
  File "/home/erik/.config/blender/4.0/scripts/addons/mitsuba-blender/io/__init__.py", line 138, in execute
    self.converter.dict_to_xml()
  File "/home/erik/.config/blender/4.0/scripts/addons/mitsuba-blender/io/exporter/__init__.py", line 108, in dict_to_xml
    self.xml_writer.process(self.export_ctx.scene_data)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 644, in process
    self.write_dict(self.scene_data[Files.MAIN])
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packa... truncated
Traceback (most recent call last):
  File "/home/erik/.config/blender/4.0/scripts/addons/mitsuba-blender/io/__init__.py", line 138, in execute
    self.converter.dict_to_xml()
  File "/home/erik/.config/blender/4.0/scripts/addons/mitsuba-blender/io/exporter/__init__.py", line 108, in dict_to_xml
    self.xml_writer.process(self.export_ctx.scene_data)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 644, in process
    self.write_dict(self.scene_data[Files.MAIN])
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 596, in write_dict
    value = self.format_path(value, self.current_tag())
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 534, in format_path
    copy2(filepath, target_path)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/shutil.py", line 434, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/shutil.py", line 234, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/erik/software/blender-4.0.0-linux-x64/textures/Thick_Eye_Texture_Inner_Baked.png' and './textures/Thick_Eye_Texture_Inner_Baked.png' are the same file
Traceback (most recent call last):
  File "<blender_console>", line 1, in <module>
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/scripts/modules/bpy/ops.py", line 109, in __call__
    ret = _op_call(self.idname_py(), kw)
RuntimeError: Error: Python: Traceback (most recent call last):
  File "/home/erik/.config/blender/4.0/scripts/addons/mitsuba-blender/io/__init__.py", line 138, in execute
    self.converter.dict_to_xml()
  File "/home/erik/.config/blender/4.0/scripts/addons/mitsuba-blender/io/exporter/__init__.py", line 108, in dict_to_xml
    self.xml_writer.process(self.export_ctx.scene_data)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 644, in process
    self.write_dict(self.scene_data[Files.MAIN])
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 581, in write_dict
    self.write_dict(value)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 596, in write_dict
    value = self.format_path(value, self.current_tag())
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/site-packages/mitsuba/python/xml.py", line 534, in format_path
    copy2(filepath, target_path)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/shutil.py", line 434, in copy2
    copyfile(src, dst, follow_symlinks=follow_symlinks)
  File "/home/erik/software/blender-4.0.0-linux-x64/4.0/python/lib/python3.10/shutil.py", line 234, in copyfile
    raise SameFileError("{!r} and {!r} are the same file".format(src, dst))
shutil.SameFileError: '/home/erik/software/blender-4.0.0-linux-x64/textures/Thick_Eye_Texture_Inner_Baked.png' and './textures/Thick_Eye_Texture_Inner_Baked.png' are the same file
Location: /home/erik/software/blender-4.0.0-linux-x64/4.0/scripts/modules/bpy/ops.py:109

Environment (please complete the following information):

merlinND commented 5 months ago

Hello @Oberschnulli,

Given the error message:

shutil.SameFileError: '/home/erik/software/blender-4.0.0-linux-x64/textures/Thick_Eye_Texture_Inner_Baked.png' and './textures/Thick_Eye_Texture_Inner_Baked.png' are the same file

It seems like a problem related to the particular scene or sequence of scenes that you are trying to export. A minimal reproducer script + the input scenes will likely be needed to investigate.