# Connecting A Node Group Between Principled and Output Shaders With Python

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)


• material_output = bpy.context.active_object.active_material.node_tree.nodes.get('Material Output') – batFINGER May 16 at 17:11
• 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/… – batFINGER May 21 at 14:39