While trying to link two nodes via python I get this error:
AttributeError: 'set' object has no attribute 'output'
I can't understand why, following the docs seems to be correct the code, which is:
def compile_met(image_selected):
# switch on nodes and get reference
bpy.context.scene.use_nodes = True
tree = bpy.context.scene.node_tree
prev = bpy.context.area.type
bpy.context.area.type = 'NODE_EDITOR'
area = bpy.context.area
# clear default nodes
for node in tree.nodes:
tree.nodes.remove(node)
# create input image node
image_node = bpy.ops.node.add_file( filepath=image_selected)
comp_node = bpy.ops.node.add_and_link_node(type="CompositorNodeComposite")
# link nodes
links = tree.links
link = links.new(image_node.output['Image'], comp_node.input[1])
bpy.context.area.type = prev
Any ideas?