Im curious of how to automate creation of shader nodes and and end up with an image texture connected to the color-input of a Principled BSDF.

This would have been easy if copy-pasting from info-console was possible as it is with creating and smoothing a mesh for instance, but for some reason doesnt work here. (I have made sure to enable nodes)

Obviously I'm fairly new to scripting in Blender.

Any response is greatly appreciated :)

  • $\begingroup$ Thank you! Probably but I'm getting an error at the line: nodes = mat.node_tree.nodes $\endgroup$
    – vilhelm
    Jul 25 at 18:03
  • $\begingroup$ From console: AttributeError: 'NoneType' object has no attribute 'node_tree' $\endgroup$
    – vilhelm
    Jul 25 at 18:03
  • $\begingroup$ No problem. Create a material in the first place and enable 'use nodes', then run the script (... and set the path to your texture). $\endgroup$
    – brockmann
    Jul 25 at 18:06
  • $\begingroup$ Fantastic, thanks. That got us past that, but seems to be one last problem with the path From console: RuntimeError: Error: Cannot read 'C: estImg\ironman_whammmm.jpg': Invalid argument $\endgroup$
    – vilhelm
    Jul 25 at 18:36
  • 1
    $\begingroup$ You are a hero. It worked. $\endgroup$
    – vilhelm
    Jul 25 at 18:51