ノードを追加
import bpy
nodetree = bpy.context.active_object.material_slots["Material-red"].material.node_tree
nodes = nodetree.nodes
nodes.new('ShaderNodeBsdfDiffuse')
ノードを削除
import bpy
nodetree = bpy.context.active_object.material_slots["Material-red"].material.node_tree
nodes = nodetree.nodes
nodes.remove( nodes['Diffuse BSDF'] )
ノード同士を接続
import bpy
nodetree = bpy.context.active_object.material_slots["Material-red"].material.node_tree
nodes = nodetree.nodes
diffuse = nodes['Diffuse BSDF']
MaterialOutput = nodes['Material Output']
nodetree.links.new(diffuse.outputs[0],MaterialOutput.inputs[0])
ノードのラベルを変更
import bpy
nodetree = bpy.context.active_object.material_slots["Material-red"].material.node_tree
nodes = nodetree.nodes
diffuse = nodes['Diffuse BSDF']
diffuse.label = "Diffuse BSDF -added"