0

I am aware I could do

material_output = bpy.data.materials[bpy.context.active_object.active_material.name].node_tree.nodes.get('Material Output')
    material_output.location = (600,400)
    principled_node = bpy.data.materials[bpy.context.active_object.active_material.name].node_tree.nodes.get('Principled BSDF')
    principled_node.location = (100,400)

    link = bpy.data.materials[bpy.context.active_object.active_material.name].node_tree.links.new

    link(principled_node.outputs[0], dust_node.inputs[0])
    link(dust_node.outputs[0], material_output.inputs[0])

But I want the node group to connect between the shader output and the main output, regardless of what the final shader is - Whether it be mix or principled, I just want it to connect between that last connection.

Is this possible?

Ned
  • 31
  • 2
  • 2
    material_output = bpy.context.active_object.active_material.node_tree.nodes.get('Material Output') – batFINGER May 16 '20 at 17:11
  • That is exactly the same as what I put in my question? – Ned May 21 '20 at 13:44
  • 1
    Yes both bpy.data.materials[bpy.context.active_object.active_material.name] and bpy.context.active_object.active_material (if they exist) are references to same material. Totally unnecessary to use name from one reference to reference samel from materials collection. Related https://blender.stackexchange.com/questions/145882/blender-scripting-connect-nodes – batFINGER May 21 '20 at 14:39
  • Ok but that wasn't the question, – Ned May 27 '20 at 18:08

0 Answers0