0
$\begingroup$

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?

$\endgroup$
  • 1
    $\begingroup$ material_output = bpy.context.active_object.active_material.node_tree.nodes.get('Material Output') $\endgroup$ – batFINGER May 16 at 17:11
  • $\begingroup$ That is exactly the same as what I put in my question? $\endgroup$ – Ned May 21 at 13:44
  • $\begingroup$ 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 blender.stackexchange.com/questions/145882/… $\endgroup$ – batFINGER May 21 at 14:39
  • $\begingroup$ Ok but that wasn't the question, $\endgroup$ – Ned May 27 at 18:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.