algorithmic modeling for Rhino
Hallo GH Forum,
I have a problem and i hope one can help me.
I have a list of Points (x values) and want to create the y- value for each, depending on the previous x.
for example, as shown in the image, it should work like that:
- start with first Rectangle (R1) and set y value to 0.
- next Rectangle (R2) check if P2start (x value) is bigger than P1end.
- if yes, set y to 0.
- ( if not, set y + 1)
- As seen on R4: P4start is smaller than P3end, so y = 0+1
- and on R5: P5start is smaller than P4end, so y=1+1
- P6start ist not smaller than P5end, so set y to 0 again
and so on..
Thanks in advance
Tags:
Hi Nickudi,
Are your numbers always integers? I just ask because there may be a trick that can be used in that case.
--
David Rutten
david@mcneel.com
Tirol, Austria
Hi David,
the x values are based on dates, so i chose them to be (timestamp) integers. the endpoints are floating, but can be rounded to be integers...
so if they should be integers, i decide them to be...
because i like tricks ;)
Even the trick is proving very difficult to do without scripting though. I may have been optimistic.
Writing a VB or C# script for this would be trivial, but I'm still trying to come up with a 'proper' solution.
--
David Rutten
david@mcneel.com
Tirol, Austria
when i thought about it first, i thought it would be quite easy to achieve as well...
but even without the solution i kind of like it, when its more tricky and you of course when you are optimictic ;)
Ok, I'm getting nowhere and it's my turn to cook dinner tonight so I don't have much time left. I attached a VB script which provides the 'elevation' for each interval. It does however have severe limitations:
--
David Rutten
david@mcneel.com
Tirol, Austria
looks super smart to me...i will try it right now and let you know...
thanks a lot for helping again, enjoy your dinner and if you need to know something about cooking, let me know, i try to help you with that... ;)
Oops.
--
David Rutten
david@mcneel.com
Tirol, Austria
And the better one. Still requires sorted input, but handles falling back to all previous blocks.
--
David Rutten
david@mcneel.com
Tirol, Austria
from my input lists, only the Pstart is sorted (points can have the same x-value, but never less)...because all blocks are not equal in length, the Pend list is not sorted and can have bigger values for x than the previous.
I hope this can be seen in the image above.
Perhaps it helps when i describe exactly what my input is:
i took articles from an newspaper archive, parsed them and have an output excel spreadsheet, which i import to gh via ghowl.
The data in each line are timestamp (for xvalue), textsizeArticle (textsize + timestamp = P end), title (text inside each block) and Ressort in Newspaper (for example colourcode for blocks).
because the textsizes vary a lot, this list is not sorted, but needs to keep the correspondence to its Pstart.
When I said "sorted", I did mean only the start of each block. It's ok if the ends are not.
Why is every block in your image higher than the previous one? It seems you are not defining the end of the domain depending on your text-size.
--
David Rutten
david@mcneel.com
Tirol, Austria
Welcome to
Grasshopper
© 2025 Created by Scott Davidson.
Powered by