Skip to content

A few 3DCodeData factory scripts fail to execute in Blender 5.0.1 #1

Description

@llada60

Thanks for the great benchmark!

I ran a full executability sweep over all Blender 5.0.1 scripts with names ending in factory; nearly all ran cleanly, but three failed.

Environment

  • Blender 5.0.1

Sweep result: of all factory .py + _geo.py scripts, only the 3 below fail to execute.


1. CanFactory/CanFactory_geo.py

Symptom

File "CanFactory/CanFactory_geo.py", line 473, in <module>
    (make_text_label, 1.0),
NameError: name 'make_text_label' is not defined

Fix
Added the missing """ at line 362 and line 388 to properly close/open the docstrings, so make_text_label (and the neighboring material constructor) parse as real functions again. Root cause was a docstring-quoting issue, not the call site.


2. LeafMapleFactory/LeafMapleFactory.py

Symptom

File "LeafMapleFactory/LeafMapleFactory.py", line 340, in make_nodegroup_sub_vein
    mix.inputs['Fac'].default_value = 0.9
KeyError: 'bpy_prop_collection[key]: key "Fac" not found'

Debug — shared root cause with #3
Both scripts mis-address the ShaderNodeMix node (Blender 4.0+ replacement for the legacy ShaderNodeMixRGB). On the new node the socket names changed and are duplicated per data-type, so name-based lookups like 'Fac' / 'Color1' either don't exist or hit the wrong-typed variant. Probing ShaderNodeMix with data_type='RGBA' in Blender 5.0.1 gives:

INPUTS:  [0] Factor(Float)  [1] Factor(Vector)  [2] A(Float)  [3] B(Float)
         [4] A(Vector) [5] B(Vector)  [6] A(RGBA)  [7] B(RGBA)  ...
OUTPUTS: [0] Result(Float)  [1] Result(Vector)  [2] Result(RGBA)  ...

So for RGBA mixing the correct sockets are Factor=inputs[0], A=inputs[6], B=inputs[7], Result=outputs[2] — and these must be addressed by index, not by name (names are ambiguous/duplicated).

Here make_nodegroup_sub_vein used mix.inputs['Fac'], mix.inputs['Color1'], mix.inputs['Color2'], and mix.outputs[0] — all legacy MixRGB socket names/indices.

Fix (make_nodegroup_sub_vein, ~L339-346)

mix = ng.nodes.new('ShaderNodeMix'); mix.data_type = 'RGBA'
mix.inputs[0].default_value = 0.9                     # Factor
ng.links.new(noise.outputs['Color'], mix.inputs[6])  # A (RGBA)
ng.links.new(comb.outputs[0],        mix.inputs[7])  # B (RGBA)
...
ng.links.new(mix.outputs[2], vor.inputs['Vector'])   # Result (RGBA)

3. BoulderPileFactory/BoulderPileFactory.py

Symptom

File "BoulderPileFactory/BoulderPileFactory.py", line 235, in make_mountain_material
    ao_mix.inputs[1].default_value = (0.0, 0.0, 0.0, 1.0)
ValueError: bpy_struct: item.attr = val: sequences of dimension 0 should contain 3 items, not 4

Debug — same ShaderNodeMix socket-layout issue as #2
The code assigned an RGBA 4-tuple to ao_mix.inputs[1], but on ShaderNodeMix inputs[1] is the Vector Factor (3 components) — hence "should contain 3 items, not 4". The RGBA color inputs are inputs[6]/inputs[7]. Three ShaderNodeMix (RGBA) blocks were affected — make_mountain_material (~L233) and two in make_stone_material (~L406, ~L434) — each using inputs[1]/inputs[2] for colors and outputs[0] for the result.

Fix — addressed all three blocks by index (Factor=inputs[0], A=inputs[6], B=inputs[7], Result=outputs[2]):

Block 1 — make_mountain_material (AO mix):

ao_mix = nt.nodes.new("ShaderNodeMix"); ao_mix.data_type = "RGBA"
ln(_fac_output(amb_occl), ao_mix.inputs[0])             # Factor
ao_mix.inputs[6].default_value = (0.0, 0.0, 0.0, 1.0)   # A (RGBA)   was inputs[1]
ln(ramp.outputs[0], ao_mix.inputs[7])                   # B (RGBA)   was inputs[2]
...
ln(layered_color.outputs[2], color_mul.inputs[0])       # Result(RGBA)  was outputs[0]

Block 2 — make_stone_material (cr2/cr1 mix):

mix = nt.nodes.new("ShaderNodeMix"); mix.data_type = "RGBA"
ln(cr2.outputs["Color"], mix.inputs[0])                 # Factor
ln(cr1.outputs["Color"], mix.inputs[6])                 # A (RGBA)   was inputs[1]

Block 3 — make_stone_material (stone_base_color mix):

stone_base_color = nt.nodes.new("ShaderNodeMix"); stone_base_color.data_type = "RGBA"
ln(mix.outputs[2], stone_base_color.inputs[0])                   # Result(RGBA)->Factor  was outputs[0]
stone_base_color.inputs[6].default_value = (0.0, 0.0, 0.0, 1.0)  # A (RGBA)   was inputs[1]
ln(cr_base.outputs["Color"], stone_base_color.inputs[7])         # B (RGBA)   was inputs[2]
...
ln(stone_base_color.outputs[2], bsdf.inputs["Base Color"])       # Result(RGBA)  was outputs[0]

Thanks for reviewing this. The affected scripts now execute successfully in Blender 5.0.1.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions