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

Trying to export with "Remove Armature Object" enabled causes "AttributeError: 'NoneType' object has no attribute 'children'" under certain conditions #2436

Open
saturday06 opened this issue Dec 10, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@saturday06
Copy link

Describe the bug

Trying to export the armature and mesh as a GLB file while "Remove Armature Object" is enabled will result in an "AttributeError: 'NoneType' object has no attribute 'children'" and the export will fail under certain conditions.

22:14:22 | INFO: Starting glTF 2.0 export
22:14:22 | INFO: Extracting primitive: Triangle
22:14:22 | INFO: Primitives created: 1
Traceback (most recent call last):
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\__init__.py", line 1313, in execute
    res = gltf2_blender_export.save(context, export_settings)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 37, in save
    json, buffer = __export(export_settings)
                   ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 55, in __export
    __gather_gltf(exporter, export_settings)
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_export.py", line 202, in __gather_gltf
    active_scene_idx, scenes, animations = gltf2_blender_gather.gather_gltf2(export_settings)
                                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 31, in gather_gltf2
    scenes.append(__gather_scene(blender_scene, export_settings))
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_gather_cache.py", line 37, in wrapper_cached
    result = func(*args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_gather.py", line 123, in __gather_scene
    vtree.add_neutral_bones()
  File "C:\Program Files\WindowsApps\BlenderFoundation.Blender4.2LTS_4.2.4.0_x64__ppwjx1n5r4v9t\Blender\4.2\scripts\addons_core\io_scene_gltf2\blender\exp\gltf2_blender_gather_tree.py", line 822, in add_neutral_bones
    self.nodes[n.armature].node.children.append(neutral_bone)
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
AttributeError: 'NoneType' object has no attribute 'children'

To Reproduce

  1. Open the attached remove-armature-object-debug-20241210.blend
  2. Go to the glTF exporter (File > Export > glTF 2.0 (.glb/.gltf))
  3. Enable the "Remove Armature Object" option
  4. Attempt to export the file

Expected behavior

The export should not fail.

Screenshots

remove-armature-object-debug-20241210.mp4

.blend file/ .gltf (mandatory)

remove-armature-object-debug-20241210.zip

Version

  • OS: Windows 11 24H2
  • Blender Version 4.2.4, 4.3.0

Additional context

Original bug report is saturday06/VRM-Addon-for-Blender#675

@julienduroure
Copy link
Collaborator

Hello,
Confirmed.
This happen only when some vertices are not assigned to any bones (so glTF exporter create a neutral joint to assign these vertices to it)

@julienduroure julienduroure added the bug Something isn't working label Dec 10, 2024
@julienduroure
Copy link
Collaborator

Well,

There is no easy fix about it:

  • We check if we can remove the armature object at start of the process, without knowing yet if a neutral bone is required
  • The addition of the neutral bone is calculated during the mesh/skin extraction
  • If the armature is at root of the scene, we cannot add the neutral bone, as we must have in glTF a unique root joint (see error SKIN_NO_COMMON_ROOT in validator). So ... If we remove the armature and add a neutral bone, the glTF file is not valid

Investigation / thinking in progress

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants