Preventing list from wrapping around
Hello there,
I have a list of strings that I want to output on a grid via a lookup on a csv file.
However, the list starts to wrap once all elements are exhausted instead of leaving the end blank. How do I prevent this behavior?
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 john on 18 Jan, 2016 08:05 AM
Hi Adi,
If your grid is one-dimensional (a single row or column) all you have to do is make the total number of points in the grid (e.g the number of rows in a one-column grid) match the total number of strings. You could also use a stack node instead of a grid node.
But I'm guessing you have a two-dimensional grid. In that case, the easiest way is to use a slice node. If the grid is producing more positions than you need you can simply slice off what you need and discard the rest.
I have attached a very simple NodeBox network (and screenshot) to illustrate this. Just feed the output of the textpath node into a slice node. Set the start index of the slice to 0 and the size to the number of strings.
In order to avoid recoding this every time you change the number of strings, you can use a count node to get the number of strings and feed that into the size node.
In this example I have a list of 7 fruits displayed using a 3 x 3 grid. The textpath node produces nine text paths, with the first two fruits repeating. I feed this into a slice node which keeps the first 7 text paths and discards the remaining two.
Hope this helps!
John
Support Staff 2 Posted by john on 18 Jan, 2016 08:24 AM
P.S. In my example I put the slice node below the textpath node so that you could easily verify the wrapping behavior that occurs before the slice. But it would be slightly more efficient to feed the grid directly into the slice and then feed the slice into the textpath node. That way NodeBox doesn't waste time making unnecessary text paths that then have to be discarded.
When I first started NodeBox it may not have occurred to me to do this. I thought of the grid as a kind of pristine abstraction, like graph paper. But it's just a list of positions like any other list.
3 Posted by Adi Ron on 18 Jan, 2016 12:19 PM
Thank you. I managed to figure it out with your help.