I am attempting to make a python script that creates a nodegroup based on some scene properties, however the group_make
operator needs to be in a node editor context to run.
It seems awkward to try and make a node view temporarily while the script is running, as the plan is to create the nodegroup with a fake user and have the user add it from the add menu in the node editor.
How should I go about this?
Update: I have found that you can create node groups without a node editor with bpy.data.node_groups.new
(thanks to ideasman42's comment here), however I still can't figure out how to add nodes to it.
How can I edit the nodes inside nodegroup without a node editor?
I can't find node_tree
for my node group. Here is my problem:
eq_node = bpy.data.node_groups.new("Equal", "ShaderNodeTree")
tree = eq_node.node_tree #This gives "no such attribute 'node_tree'". How can I acces the node tree of the node group?
nodes = tree.nodes
links = tree.links
#Create nodes in node group here with nodes.new