0
$\begingroup$

I am trying to check material nodes on a mesh with Python scripting. I was using a Iridescence material. In this material, there are two different output nodes named "Material Output" and "gltf Material Output". With scripting I can check "Material Output" node but I could not able to achieve "gltf Material Output". How can I check this node exist in material?

Script:

import bpy

obj = bpy.data.objects["lamp_transmission"]
material_slots = obj.material_slots
for m in material_slots:
    material = m.material
    print("slot", m, "material", material)
    inputs = material.node_tree.nodes
    for i in inputs:
        print(i.type)

Output: enter image description here

Material: enter image description here

$\endgroup$
7
  • $\begingroup$ Try print(i.name) It's outputting "Group" because that's it type, not it's name. $\endgroup$
    – Psyonic
    Mar 31, 2023 at 7:27
  • $\begingroup$ Same output when I tried to print i.name $\endgroup$
    – dasmehdix
    Mar 31, 2023 at 7:51
  • $\begingroup$ Try i.label...... $\endgroup$
    – Psyonic
    Mar 31, 2023 at 9:20
  • $\begingroup$ Side note, in shader jargon inputs refers to the little dots on the left of the nodes which are used for linking to the outputs on the right of other nodes , naming the nodes inputs is very confusing :) $\endgroup$
    – Gorgious
    Mar 31, 2023 at 12:55
  • 1
    $\begingroup$ Please provide your blend file in the question $\endgroup$
    – Karan
    Apr 1, 2023 at 14:17

1 Answer 1

1
$\begingroup$
import bpy

object = bpy.data.objects["lamp_transmission"]

if object.material_slots:
    for slot in object.material_slots:
        if slot.material and slot.material.use_nodes:
            for node in slot.material.node_tree.nodes:
                if node.type == 'GROUP' and node.node_tree.name == 'gltf Material Output':
                    print(node)
$\endgroup$

You must log in to answer this question.

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