Page MenuHome

Including node group attribute into NodeTreePath
Needs Triage, NormalPublicDESIGN

Description

At this moment SpaceNodeEditorPath has method append with parameters node_tree and node. This method is adding NodeTreePath into path. But event if node parameter was added into append method the NodeTreePath object does not have any information about root node of group tree.

https://docs.blender.org/api/current/bpy.types.SpaceNodeEditorPath.html#bpy.types.SpaceNodeEditorPath.append
https://docs.blender.org/api/current/bpy.types.NodeTreePath.html

According the fact that one group tree can be used by many group nodes it quite important to have information about via which group node the group tree is eddited. Sverchok addon is used to color problem nodes. Without information about group nodes in path it is impossible to mark such nodes.

I would not bother if there was any workaround. What I actually was trying:

node_tree_path.name = 'group_node'
AttributeError: 'NodeTreePath' object has no attribute 'name'

bpy.types.NodeTreePath.node = bpy.props.StringProperty()
node_tree_path.node = 'name'
AttributeError: 'NodeTreePath' object attribute 'node' is read-only

node_tree_path['node_name'] = 'name'
TypeError: bpy_struct[key] = val: id properties not supported for this type

area_names = {}
area_names[node_tree_path] = 'my_name'

Even last example would not work for several reasons. ID of path can be changed on undo event for example. If area is splitting into two I'm not able to update second area in the dictionary.

I think, for API consistency, either node parameter should be removed out from the update method or node attribute should be added to NodeTreePath object. I would prefer second choice.

Event Timeline

Philipp Oeser (lichtwerk) changed the task status from Needs Triage to Needs Information from User.EditedMar 19 2021, 6:34 PM

I am not exactly sure if I understand correctly.

(note: it is always useful to have an example file where some of this is set up already, just speeds up the process a bit, this was lacking here).

So I have a test file:

And I thought I got what you are after (see my comment in the file), but I am not sure I understand your usecase:

  • if a node makes problems in a tree, shouldnt all group nodes using the tree have problems?
  • not sure yet why you really have to pass the node to SpaceNodeEditorPath.append() -- you are right, on first sight this seems not necessary.

Anyways, would like to hear about my first question first.

Sorry, did not thought that example file will be useful here.

It's possible to consider node group as a function. Its output is dependent on what was passed into its input. In the video below I show example of two nodes which share the same node group.

The difference is in input data. Second node purposely has senseless connection so it could produce an error. For debug purposes we color error nodes with red color in Sverchok. So when I'm entering node group of the second node I can see which cause the error. There is no error in node group of first node so there is no nodes with red color there.

Without information from UI about which node is root of an opened node group it's impossible to show any debug information because execution context is not known. I have to store this information in a node group tree and update this information via entering into node group operator so it could work. But solution is really fragile. If there is several node editors opened then one editor can override the variable and broke the logic.

If path could store any information about root node it would help greatly.

Philipp Oeser (lichtwerk) changed the task status from Needs Information from User to Needs Triage.Mar 22 2021, 12:53 PM

Ah, get it now.

@Jacques Lucke (JacquesLucke) might also be interested here.

It might be good to keep an eye on D10874: Nodes: Separate node name and display name in bNodeTreePath. -- or join the discussion there.

Campbell Barton (campbellbarton) changed the subtype of this task from "Report" to "Design".Wed, Apr 28, 4:13 PM