1
$\begingroup$

I am using Lucas Roedel's pixel art addon. (https://lucasroedel.gumroad.com/l/pixel_art) I am encountering a problem that says: AttributeError: 'ShaderNodeTree' object has no attribute 'output'

Here is the section of the code that is wrong. I have looked at some discussions and apparently, Blender 4.0 removed outputs from node_groups in their API. I have tried some workarounds by adding some sockets, but there is another error code that says: Cannot add sockets to built-in nodes.

Can anyone recreate this error and provide a fix, please? Also, I have tried using both version 1 and 1.1 from the addon and they both have the same problem. Thanks for the help.

# Creates a group for the dithering part
for group in bpy.data.node_groups:
    if group.name == 'Dithering':
        bpy.data.node_groups.remove(group)

ditherGroup = bpy.data.node_groups.new('Dithering', 'ShaderNodeTree')
ditherGroup.outputs.new("NodeSocketColor", "Color")

outputNode = ditherGroup.nodes.new("NodeGroupOutput")
outputNode.location = (0, 0)

Here is the complete error output, it also mentions something about line 534, but I didn't really understand what was wrong:

Python: Traceback (most recent call last): 
File "C:...\AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\PixelArtAddon_v_1_1.py", line 534, in execute
    multiple_material(context)
File "C:...AppData\Roaming\Blender Foundation\Blender\4.1\scripts\addons\PixelArtAddon_v_1_1.py", line 304, in multiple_material
    ditherGroup.outputs.new("NodeSocketColor", "Color")
    ^^^^^^^^^^^^^^^^^^^
AttributeError: 'ShaderNodeTree' object has no attribute 'outputs'
$\endgroup$
0

1 Answer 1

2
$\begingroup$

There are examples of porting code in the 4.0 release notes.

Old

ditherGroup.outputs.new("NodeSocketColor", "Color")

New

ditherGroup.interface.new_socket("Color", in_out='OUTPUT', socket_type="NodeSocketColor")
$\endgroup$

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