Fixing AttributeError: 'NoneType' object has no attribute 'nodes'

I wondered myself why big scenes fail to build :thinking:

nodes = mat.node_tree.nodes
AttributeError: ‘NoneType’ object has no attribute ‘nodes’

This is easy solvable, by making all materials “use nodes”, so just go:

import bpy

for mat in bpy.data.materials:
mat.use_nodes = True

yeah :relaxed:

Hm that should not happen, in what file / line are you getting this? I can fix that.

nodes = mat.node_tree.nodes
AttributeError: ‘NoneType’ object has no attribute ‘nodes’

I receive this error in

Exporting Scene
Scene exported in 0.017000913619995117
Traceback (most recent call last):
File “D:\Program Files\ArmorySDK//armory/blender\arm\nodes_logic.py”, line 106
, in draw
mat.use_nodes = True
AttributeError: ‘NoneType’ object has no attribute ‘nodes’

location: :-1

location: :-1

I’m unable to solve it with suggested by linuz method. Most likely because Idk where to put the code. However, I’ve “fixed” that by enabling “Use nodes” in Shader editor of Light object (material?).

Hi, it looks like you’re using a pretty old SDK version? You should update to 2020.09, the code in your error message doesn’t even exist anymore.

Hi!
It’s not so old - 2020.7.0. Thank you for the advice, I’ll consider update