Moguri / blend2bam

A CLI tool to convert Blender blend files to Panda3D BAM files
MIT License
66 stars 17 forks source link

RuntimeError: Operator bpy.ops.object.mode_set.poll() failed #22

Closed tito closed 4 years ago

tito commented 4 years ago

Using latest blend2bam 0.10, i hit a crash:

 $ blend2bam untitled.blend ./untilted.bam
Blender version is 2.8+, forcing gltf28 pipeline
Blender 2.81 (sub 16) (hash f1aa4d18d49d built 2020-01-28 02:41:53)
Read prefs: /home/tito/.config/blender/2.81/config/userpref.blend
srcroot: /home/tito/Downloads
Exporting: ['/home/tito/Downloads/untitled.blend']
Export to: /tmp
Read blend: /home/tito/Downloads/untitled.blend
Converting .blend file (/home/tito/Downloads/untitled.blend) to .gltf (/tmp/untitled.gltf)
Traceback (most recent call last):
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blend2gltf/blender28_script.py", line 106, in main
    export_gltf(settings, src, dst)
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blend2gltf/blender28_script.py", line 66, in export_gltf
    make_particles_real()
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blend2gltf/blender28_script.py", line 8, in make_particles_real
    bpy.ops.object.mode_set(mode='OBJECT')
  File "/usr/share/blender/2.81/scripts/modules/bpy/ops.py", line 201, in __call__
    ret = op_call(self.idname_py(), None, kw)
RuntimeError: Operator bpy.ops.object.mode_set.poll() failed, context is incorrect
Filed to convert /home/tito/Downloads/untitled.blend to gltf
Traceback (most recent call last):
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/cli.py", line 96, in convert
    src2tmp.convert_single(srcfile, tmpfile.name)
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blend2gltf/__init__.py", line 46, in convert_single
    self.convert_batch(srcroot, dstdir, files)
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blend2gltf/__init__.py", line 61, in convert_batch
    blenderutils.run_blender_script(self.script_file, args, blenderdir=blenderdir)
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blenderutils.py", line 16, in run_blender_script
    blenderdir=blenderdir
  File "/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blenderutils.py", line 7, in run_blender
    subprocess.check_call([binpath, '--background'] + args, stdout=None)#subprocess.DEVNULL)
  File "/home/tito/.conda/envs/oman/lib/python3.7/subprocess.py", line 363, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['blender', '--background', '-P', '/home/tito/.conda/envs/oman/lib/python3.7/site-packages/blend2bam/blend2gltf/blender28_script.py', '--', '/tmp/tmpmkbnuibn', '/home/tito/Downloads', '/tmp', '/home/tito/Downloads/untitled.blend']' returned non-zero exit status 1.
Failed to convert all file

Here is the file that you can try to convert: untitled.zip

tito commented 4 years ago

Removing the make_particles_real() call make it work

Moguri commented 4 years ago

For reference, this is the poll function that we're failing: https://developer.blender.org/diffusion/B/browse/master/source/blender/editors/object/object_edit.c$1394