Network not giving the results (that I) expeced
What I do:
- create a "range" node (1-10)
- create an "add" node connected to the range node
- right click and turn add node into a subnetwork
- enter the network
- create a "first" node to the add node
- set the "first" node as rendered
- leave the network and set it to rendered
what i expect:
I expect it to give me the result of the "first" node inside the network (0.0)
what I get:
the whole range of numbers.
I have attached a nodebox3 file to show the problem. I expect the network to output the same result as the two top level nodes next to it, but it doesnt.
while on the topic of nested networks:
I dont think it is a good idea to let whatever node inside the
network that is set as rendered to be the official output of it.
The reason being that if i quickly need to go in to a subnetwork
and do some work and look at what the nodes inside produce then I
dont want to risk forgetting to set the render flag back to the
right node. I have suggestions to how this could be handled if
anyone is interested.
Thanks
Gustaf
- ndbx3subNetworkHmm.ndbx 1.24 KB
Keyboard shortcuts
Generic
? | Show this help |
---|---|
ESC | Blurs the current field |
Comment Form
r | Focus the comment reply box |
---|---|
^ + ↩ | Submit the comment |
You can use Command ⌘
instead of Control ^
on Mac
Support Staff 1 Posted by Frederik De Ble... on 02 Dec, 2013 10:15 AM
Hey Gustaf,
I've looked at your network and it seems to do what is intended; that is, there is no bug in NodeBox.
The question is: what do you want to do? It looks like you're trying to sum all the numbers or something?
About the issue of the rendered node in the subnetwork: we're aware of that, it is indeed irritating and we're thinking of a fix.
2 Posted by gustaf on 02 Dec, 2013 10:30 AM
hmm. What I am trying to do is just get the first value of a list. The "add" node doesnt do anything and is only there because, well, thats how i ran in to this problem.
If you look at the result of the two nodes on the left (add+first) you see a single value as the result (0.0), right?
If you look inside the group on the right hand side you see that it has the same two nodes (add+first) inside of it, but it doesnt produce the same result. Instead of returning a single value (0.0), it returns the full range of 10 values.
Is this what you see as well? If it is, please explain why the group on the right shouldnt produce the same result as the two nodes on the left.
thanks
Support Staff 3 Posted by Frederik De Ble... on 02 Dec, 2013 10:53 AM
Okay, I see your problem. This is related to how NodeBox does list matching.
Basically, it treats the network as a function, and will call it with each element of the list. In your case, that means it will take the first element of the list, add zero to it, then take the first element (but there's already only one element) and return that. Then it will do the same for the second element, and append that to the bigger list. If you're familiar with functional operation, it basically performs a
map
operation over all the elements.This is the default behavior but you can change it. In the metadata for the network, select the published port and set the "range" to "list". This means that NodeBox will work on the entire list at once, not one-by-one. Then you see that the network works as the nodes in the root.
For more information, you can read How NodeBox Works, specifically the part on list matching.
Hope this helps!
F
Support Staff 4 Posted by Frederik De Ble... on 02 Dec, 2013 10:54 AM
Here's a screenshot showing the metadata setting:
5 Posted by gustaf on 02 Dec, 2013 09:19 PM
aaaaaaaaaah slaps forhead
May I give a suggestion for the subnetwork output? Having special "input" and "output" nodes that you put inside the network that creates a virtual bridge to the parent nodes in and out points seems to work very well in other programs.
Could also avoid any backwards compatibility issues with some kind of "if (no output nodes exist) then output the render-flagged node" ?
Support Staff 6 Posted by Frederik De Ble... on 03 Dec, 2013 09:59 AM
Yes – having "inlets" and an "outlet" is something we're considering, since the issue you mention causes lots of confusion. This requires a conversion from published ports to inlets/outlets.
I've added an issue that tracks this: https://github.com/nodebox/nodebox/issues/368