Moguri / blend2bam

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

Error when linking collection containing armature. #54

Closed janEntikan closed 3 years ago

janEntikan commented 3 years ago

When exporting a blend file that has one or more linked collections with an armature it produces the following error:

Exporting: ['/home/momojohobo/mahshizz/Development/armature_instance_example/fixme.blend']
Export to: /tmp/
Read blend: /home/momojohobo/mahshizz/Development/armature_instance_example/fixme.blend
Info: Read library:  '/home/momojohobo/mahshizz/Development/armature_instance_example/swaybox.blend', '//swaybox.blend', parent '<direct>'
Info: Read library:  '/home/momojohobo/mahshizz/Development/armature_instance_example/swaybox.blend', '//swaybox.blend', parent '<direct>'
Converting .blend file (/home/momojohobo/mahshizz/Development/armature_instance_example/fixme.blend) to .gltf (/tmp/fixme.gltf)
Error: ViewLayer 'View Layer' does not contain object 'legs'
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/blend2bam/blend2gltf/../blender_script_common.py", line 32, in convert_files
    convertfn(settings, src, dst)
  File "/usr/lib/python3.9/site-packages/blend2bam/blend2gltf/blender28_script.py", line 160, in export_gltf
    prepare_meshes()
  File "/usr/lib/python3.9/site-packages/blend2bam/blend2gltf/blender28_script.py", line 144, in prepare_meshes
    bpy.context.view_layer.objects.active = obj
RuntimeError: Error: ViewLayer 'View Layer' does not contain object 'legs'

Failed to convert /home/momojohobo/mahshizz/Development/armature_instance_example/fixme.blend to gltf
Traceback (most recent call last):
  File "/usr/lib/python3.9/site-packages/blend2bam/cli.py", line 88, in convert
    src2tmp.convert_single(srcfile, tmpfile.name)
  File "/usr/lib/python3.9/site-packages/blend2bam/blend2gltf/__init__.py", line 46, in convert_single
    self.convert_batch(srcroot, dstdir, files)
  File "/usr/lib/python3.9/site-packages/blend2bam/blend2gltf/__init__.py", line 61, in convert_batch
    blenderutils.run_blender_script(self.script_file, args, blenderdir=blenderdir)
  File "/usr/lib/python3.9/site-packages/blend2bam/blenderutils.py", line 18, in run_blender_script
    run_blender(
  File "/usr/lib/python3.9/site-packages/blend2bam/blenderutils.py", line 14, in run_blender
    subprocess.check_call([binpath, '--background'] + args, stdout=None)#subprocess.DEVNULL)
  File "/usr/lib/python3.9/subprocess.py", line 373, in check_call
    raise CalledProcessError(retcode, cmd)
subprocess.CalledProcessError: Command '['blender', '--background', '-P', '/usr/lib/python3.9/site-packages/blend2bam/blend2gltf/blender28_script.py', '--', '/tmp/tmp24fn1xv7', '/home/momojohobo/mahshizz/Development/armature_instance_example', '/tmp', '/home/momojohobo/mahshizz/Development/armature_instance_example/fixme.blend']' returned non-zero exit status 1.

Failed to convert all files

Steps to reproduce:

Or simply convert fixme.blend in the conveniently attached zip. armature_instance_example.zip

janEntikan commented 3 years ago

It has nothing to do with armatures.

for obj in bpy.data.objects:
    bpy.context.view_layer.objects.active = obj

blender28_script.py:144 Won't work on any kind of linked instances since they are not officially in the view_layer.