I'am trying to use the Python API to make a lot of different and randomized trees with the MTree add-on. But I'am struggling with an error telling me that the context is incorrect.
RuntimeError: Operator bpy.ops.node.add_node.poll() failed, context is incorrect
I've tried to use the bpy.context.active_node but that doesn't seem to exist even though it's in the documentation.
For now my code looks like this:
import bpy
bpy.ops.node.new_node_tree(type="mtree_node_tree", name="Tree1")
bpy.context.area.add_node(type="MtreeParameters", use_transform=True)
But it gives out an error which I listed before at the 3rd line. The code should just put a node into the node tree, but it probably doesn't know where to.
So does anyone know how to make the node tree the context?