New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Node groups instead of monads #3319
Comments
|
i welcome a simpler implementation of node groups in Sverchok. It must be possible. |
|
--EDIT 2--
The current method is incomplete, and is somewhat unstable (frankly the whole of Sorcar is, at the moment xD). It relies on copying selected nodes to the new group and making the connections with the default
Will be improving this soon, now that
Yes, I am in the process of implementing it. Earlier I was searching for a way to link the socket classes to the node interface. So I took another shot at the interface base class and, found out that it was the other way around. The interface class needs to register with the socket type. |
|
Yes, next code looks working, but how to draw properties on a node group node still is the issue. class ScNodeSocketInterfaceNumber(bpy.types.NodeSocketInterfaceStandard):
bl_idname = "ScNodeSocketInterfaceNumber"
bl_socket_idname = "ScNodeSocketNumber"
bl_label = "Number"
color = (0.0, 1.0, 0.0, 1.0)
default_value: FloatProperty()
default_type: StringProperty(default="NUMBER")
def draw_color(self, context):
return self.color
def draw(self, context, layout):
layout.prop(self, 'default_value') |
|
The problem is which property should be shown by socket. I guess that in Sorcar as in Sverchok a socket shows property of a node where it was initialized. This property can't be used in case of node groups because several node groups can have different parameters for one socket. The solution can be to reconsider using properties. So all default values should be kept in socket classes. But this can increase number of sockets types and in case of Sverchok it is quite significant changes which will touch very many parts of code. @aachman98 Thanks for help. I will think probably simpler solution exists. |
|
much of the complexity in ScriptNode and Monads came from the inability to dynamically set the min/max of Float and IntProperties. |
Would it help if you simply changed the parent class of all the Sverchok sockets to |
|
In Sverchok we have |
|
using set/get is not ui friendly, we do however use those in A Number and a few other places. This is a problem that could be resolved relatively easily by blender devs. |
|
ideally, if my socket has a limit, i don't want to let the user think that when they slide beyond that value that it will stick. they only realize after letting go of the slider than it jumped back to the value allowed by set/get . i consider it a kludge. but we could do that. I am not in favour. |
|
but a special socket-class that can mimic all socket types, just for the Group Node, is a possibility i do like. it could ofcourse have dynamic min/max using set/get |
|
It impossible because sockets are created automatically by Blender and their type is determined by type of sockets which was connected to group input node. |
|
historic context. #785 :) |
I get your point. Somehow, standard node sockets manage to set the slider limits, without letting users to go past them. Just tried it on a |
|
pynodes is a cool abstraction, but in practice when we try to push the boundaries these issues are all undocumented (and in some parts incompletely wrapped ) and therefore a massive time sink. |
|
I already have a half mind to replace all custom sockets in Sorcar with standard sockets ;) |
|
in some respects a lot of non-sense would be solved if we would fully define our own nodetree UI external to Blender maybe |
|
It is also interesting (node based) project: https://www.luna-lang.org/ |
|
pyflow is really cool :) |
|
also yes!! luna looks spectacular. |
|
With properties it looks much cleaner, my congratulations. If to think of it is strange how in Sverchok properties are bound to sockets. |
|
This shouldn't be a problem when creating node groups, as the link class contains from/to_socket as well as from/to_node data members. You can make the node interfaces in such a way that they link to the node rather than the sockets created in the "node group" node. It would look like a bypass where the output sockets would serve no purpose but to call EDIT: Just realised that it might look confusing at first. I'll try to make a small demo node to visualize this. Also, I have almost no experience in developing Sverchok nodes or know how they function internally, so it is possible that what I propose wouldn't work. |
|
@aachman98 this code is present for all nodes. , we could exclude if for nodes of type Line 321 in 32b697d
def idname_draw(self, context):
if not displaying_sverchok_nodes(context):
return
layout = self.layout
node = context.active_node
ntree = node.id_data
if not node:
return
if node.bl_idname in {'NodeGroupInput', 'NodeGroupOutput'}:
return
... |
|
All type of sockets can be found here. Lines 767 to 772 in a0231bd
For using node groups sockets should be fixed but this will be minor changes I guess. It looks like that main problem is fixing update system. Current implementation could be split into two parts now. First is aware of evaluating main tree and second is responsible for evaluating the monads. I think such splitting should lead to redundant code. I would prefer to see update system which could handle any tree. In this case it would be possible to evaluate all net recursively. |
|
We have a chance to got official documentation about creating node groups. |
|
There is problem which I still not sure how to solve. The only role of update system at the moment is to call I see two ways of solving the problem. It is possible to modify |
|
As far as I remember, we store contents of outputs in a dictionary, something like |
|
Probably then a node could has for node in outdated_nodes:
node.update_path = base_group_node.node_id # it looks enough to distinguish the context
node.update()
Socket:
def sv_get(socket):
if socket.node.id_data.bl_idname == 'SvGroupTree'
return sockets_data_dictionary[socket.other.node.update_path][socket.other.socket_id] |
|
It is possible too. But I was thinking about calculating the path to the node at the moment we write into |
|
How the path can be calculated at that place? |
|
don't we have a reference to the node there? Node has a reference to it's tree. Node group tree should have a reference to it's parent, I think... |
|
A node tree can have multiple parents (base group nodes) but the tree does not know from which parent, update system is calling a node. |
|
I think that has been the main unsolved bug of the monads, if you find a way to fix it probably it could also applied to them |
|
I think if node groups will work we won't need to have monads. |
|
I agree, but they will need "vectorize" and "loop" to replace them |
|
Goal of group nodes is to hide part of a tree under their interface. So tree could be splitted into simple parts and more complex trees could be builded. Loops is different conception which has nothing in common with node groups. |
|
So you plan to add some other nodes to handle looping? |
|
If I will add node groups I would like to delete monads. After that I could make refactoring of json importer again because monads are builded in that way that I had to use recursion during importing. Also after deleting monads refactoring of update system will be also doable. No other plans at the moment. |
|
We could think of several special "flow control" nodes... for example...
controlled = self.inputs['Control'].linked_node
# put values from inputs of the Loop node to inputs of controlled node
for i in range(n):
controlled.process()
# put values from outputs of controlled node to it's inputs
# put values from outputs of controlled node to outputs of the Loop node |
|
Not quite clear, how Input and Output Loop nodes will know they are paired? And where looping logic itself will live? |
|
It is possible to add property input or output nodes with name of another node or they can be connected via special sockets to each other. Logic of evaluation such things should be in update system or at least it should be aware of it and be able to pass responsibility of tree evaluation to those nodes. |
|
As I already was saying current |
What exactly it should be? |
|
Proper moment to fixing what I'm talking about is somewhere far in the future. First things first. And we should have some plan first for such architectural changes so we could do this once and not return to the issue again. Probably we could create separate issue to discuss who and which changes would like to see. |
|
i'd like to handle messive changes if there are so. |



















Monads are very complex and difficult to support. They does not use dedicated for creating node groups Blender tools. Last Sorcar updates proves that this tools can be used.
Here is the code of
node groupnode.And here is the code of creating node group operator. It is nearly all code I guess which is needed for handling node groups.
How had seen the code of monads know that this code is much simpler.
What I don't like in current implementation in Sorcar is that sockets in node group node do not have parameters. They should be plugged to other nodes for managing node group node.
@aachman98 Did not you try to use this class NodeSocketInterface for creating sockets of node group trees? Probably it could solve the problem.
I Had tried it but faced with Blender crash. Here is bug report but it has low priority and probably will be fixing for years.
The text was updated successfully, but these errors were encountered: