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?
material_output = bpy.context.active_object.active_material.node_tree.nodes.get('Material Output')
$\endgroup$bpy.data.materials[bpy.context.active_object.active_material.name]
andbpy.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$