Create material node tree using script I am trying to create a series of materials nodes that are linked together. My script successfully creates a new material and connects a Mix node to the material output node. It also creates an Ambient Occlusion node, but fails to connect that AO node to the Mix node.

import bpy

bpy.data.materials.new(name='test')
mat = bpy.data.materials.get('test')
mat.use_nodes = True

#define where output of new node will link to
matout = mat.node_tree.nodes.get('Material Output')
#define new node type to link in
newmat = mat.node_tree.nodes.new('ShaderNodeMixShader')
#create new node with link
mat.node_tree.links.new(matout.inputs[0], newmat.outputs[0])

matout = mat.node_tree.nodes.get('ShaderNodeMixShader')
newmat = mat.node_tree.nodes.new('ShaderNodeAmbientOcclusion')
mat.node_tree.links.new(matout.inputs[0], newmat.outputs[0])


The console tells me that the matout = mat.node_tree.nodes.get('ShaderNodeMixShader') fails to find anything (AttributeError: 'NoneType' object has no attribute 'inputs').

Am I approaching this wrong?
Answering my own question ...

Once it is created, the node names are different. So you create a node using, e.g. ShaderNodeMixShader, but after that it is called 'Mix Shader' (i.e. as it appears in the node panel).