0
$\begingroup$

I am using this addon: https://github.com/saturday06/VRM_Addon_for_Blender and have used it successfully before, but am getting an error code when I attempt to export it. I can't make heeads nor tails of the technical jargon- what exactly do I have to do in order to prep the model for export? enter image description here

Report: Error A Python: Traceback (most recent call last): File "C:\User: Downloads blender-2.92.0-windows64\blender-2.92.0-windows64URM_Addon_for_Blender-release\io_scene_vrm exporter init_.py", line 55, in execute bool(self.export_invisibles), bool(self.export_only_selections)

File "C:\User Downloads blender-2.92.0-windows64\blender-2.92.0-windows64\URM_Addon_for_Blender-release\io_scene_vrm exporteriglb_obj.py", line 58, in_init__ "INVOKE DEFAULT", show_successful message=False

File "C:\User: Downloads\blender-2.92.0-windows64\blender-2.92.0-windows6412.92\scripts modules\bpylops.py", line 130, in call ret = _op_call(self.idname_py(), C_dict, kw, C_exec, C_undo)

RuntimeError: Error: Python: Traceback (most recent call last): File "C:\User: Downloadsblender-2.92.0-windows64\blender-2.92.0-windows64\RM_Addon_for_Blender-release\io_scene_vrm editor validation.py", line 43, in invoke context, self.errors, self.show_successful_message

File "C:\User: Downloads blender-2.92.0-windows64\blender-2.92.0-windows64 VRM_Addon_for_Blender-release\io_scene_vrm editor validation.py", line 248, in detect_errors_and_warnings for node, material in search.shader nodes and materials(used materials):

File "C:\User: Downloadsblender-2.92.0-windows64\blender-2.92.0-windows64\VRM_Addon_for_Blender-release\io_scene_vrm editor search.py", line 11, in shader_nodes_and_materials for mat in used materials

File "C: Users Downloads blender-2.92.0-windows64 blender-2.92.0-windows64\VRM Addon for Blender-release\io scene vrm editor search.py", line 12, in if mat.node_tree is not None

AttributeError: 'NoneType' object has no attribute 'node_tree'

location: C:\User: Downloads blender-2.92.0-windows64\blender-2.92.0-windows64\2.92\scripts modules bpylops.py:130

location: :-1

$\endgroup$
3
  • $\begingroup$ I've not used this AddOn before, but, purely in terms of the technical jargon, what the error message is saying is that it encountered a None material, and that None (representing the absence of a material, if you will) has no node_tree (a "node tree" being the computational way Blender materials represent shader nodes). Specifically, it looks like this line is failing, though I'm not sure off the top of my head what the "Surface" attribute refers to: github.com/saturday06/VRM_Addon_for_Blender/blob/… $\endgroup$ Commented Dec 28, 2021 at 3:51
  • $\begingroup$ It looks like used_materials is created here: github.com/saturday06/VRM_Addon_for_Blender/blob/… If you upload your .blend file, maybe someone can execute that for loop and try to determine why a None is being appended to this list, where only materials are expected $\endgroup$ Commented Dec 28, 2021 at 4:00
  • $\begingroup$ @NeverConvex sure thing- the model is saved here: drive.google.com/drive/u/1/folders/… In the meantime I'll try looking through the materials and see if there is a part of the model that does not have a material, thank you for the response $\endgroup$
    – Halppls
    Commented Dec 28, 2021 at 5:00

1 Answer 1

1
$\begingroup$

I think I figured this problem out, but it took me a bit of digging. I've split this into a lengthy description of how I examined the problem, and then a brief description of how I believe @Halppls can fix it in their Blend file.

--Investigation/Explanation of Problem--

Following on my comments above, I ran this for loop (a slight modification of the one in the linked repo, focusing on the list that appears to contain a None value where a material is expected) in a Blender Scripting window:

>>> for mesh in [obj for obj in bpy.data.objects if obj.type == "MESH"]:
...             mesh_vertex_group_names = [g.name for g in mesh.vertex_groups]
...             for mat in mesh.data.materials:
...                 if mat is None:
...                     print(f"For {mesh}, got mat {mat}")

This printed:

For <bpy_struct, Object("Object.037")>, got mat None
For <bpy_struct, Object("Object.038")>, got mat None
For <bpy_struct, Object("Object.039")>, got mat None
For <bpy_struct, Object("Object.040")>, got mat None
For <bpy_struct, Object("Object.041")>, got mat None
For <bpy_struct, Object("Object.042")>, got mat None
... [ellipses mine; all objects between these two numbers were printed]
For <bpy_struct, Object("Object.067")>, got mat None
For <bpy_struct, Object("Object.068")>, got mat None
For <bpy_struct, Object("Object.069")>, got mat None

Selecting just Object.037 (which is the main, red part of the robot's body), I can verify that data.materials contains only the None material:

>>> [m for m in bpy.context.object.data.materials]
[None]

This is surprising, since Object.037, for example, clearly has RED set as its material. But, this is only true in the Materials sub-menu for Object -- i.e., it only has RED as a material linked to its object, not as a material linked to the data (meshes, curves, etc) making up the object. You can see this if you open this sub-menu:

enter image description here

Although you'll see that there is a material linked to the Object, switch that sub-menu to Data view, and you can see that there is only an empty materials slot on all of these objects. If we assign RED as a Data-linked material, now, then it looks like we get the behavior the AddOn expects:

>>> [m for m in bpy.context.active_object.data.materials]
[bpy.data.materials['RED']]

As an aside, this makes me wonder what the proper way to access Object-linked materials through the Python API is. It looks like this (which is not the way the VRM AddOn tries to access materials; it uses object.data.materials, which seems to only collect data-linked materials) kind of call may work, for accessing Object-linked materials:

>>> bpy.context.object.material_slots[0].material
bpy.data.materials['ORANGE']

More information on the distinction between Object and Data linked materials can be found in the relevant Blender docs:

Specifies whether the material is to be linked to the Object or to the Object Data.

The Link selector has two choices, Data and Object. These two menu choices determine whether the material is linked to the object or to the data, (e.g. a mesh or curve). The Data menu item determines that this material will be linked to the mesh’s data-block which is linked to the object’s data-block. The Object menu item determines that the material will be linked to the object’s data-block directly.

--Just The Solution--

I think you just need to go through each of objects numbered 37 to 69, go into the Materials tab, switch from Object to Data linked view, and assign the desired material(s). After this, the VRM AddOn shouldn't see None as a material on these objects any longer.

$\endgroup$
1
  • $\begingroup$ Holy cow, this is so much effort put forth into this answer! Thanks for going the extra mile to help! I'll get working on this and see if that solves all the issues. Many thanks, you are a wonderful person $\endgroup$
    – Halppls
    Commented Dec 29, 2021 at 7:47

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .