algorithmic modeling for Rhino
Hi everyone,
(images and files attached)I've been going crazy over this for an entire day without any luck. Hoping someone can help me to figure it out. I have two sets of points, 'from' and 'to'. I have the 'from' connecting to their closest 'to' based on the component setup in the file (it's a simplification of a larger file but this is how it's set up). I have lines going from each 'from' to each 'to' based on this setup.
No problems there.
But each 'to' destination has a total "capacity" of 'from' connections. At first, these connections ignored this capacity and so there are many more connections than there are supposed to be.
I want to cull those extra connections after the closest point action, and then use that newly culled point list to connect to the 'line' component. The end result should be a set of connections where the total capacity of each 'to' point is not exceeded.
I've gotten to the stage where I can find how many 'to' connections are made, but I cannot figure out for the life of me how to cull the excess points. Any help would be greatly appreciated, hopefully the file makes clear where I have not, I've tried to make the file as clean as possible.
Tags:
OK, here we are:
1. The phase A thingy (taken from a myriad of C# things that I have for random stuff) does the test data (in 2 modes, using 2 methods and one Unix [highly] trained cat).
2. The phase B thingy is custom made for you (about 20 minutes work). If you provide the correct from/toDT stuff > the C# works with your data, if not works with phase A demo data.
3. I really can't see any chance for duplicate lines: in the closest mode we iterate once (for every fromDT point) and in the random mode we iterate attempts per point times (but I've used a classic List.Distinct().ToList() filter in order to avoid potential duplicates).
4. Relating many humans with (less) many jobs... well it has some meaning but randomly doing it? (anyway ... urban stuff is definitely a mysterious stuff).
5. No extensive error checks are included (yet) so handle with care - or wait for the (far better) V3.
May the Force (the dark option) be with us all.
best, Lord Of Darkness, Ruler of SardineLand, Prince Of Something
Hi Peter, thank you so much. You've caught me on the cusp of bedtime. I'm looking forward to trying to understand this tomorrow morning haha. BTW, what do you mean by 'I really can't see any chance for duplicate lines'?
Thanks again,
Andrew
Well ... I've just added 2-3 lines of code to indicate that thingy:
Imagine a fromPoint hitting randomly toPoints (attempts times, stored as explained already). This is done via a classic "method":
but (better safe than sorry) in order to avoid (pointless if you ask me) potential duplicate values I've used the List.Distinct().ToList() method 2 lines below. This means that you MAY have N attempts on hand and get N-something lines (where something = the sum of all duplicate values counted [and removed] in the whole loop) :
get the V3 that informs you about all that deep space stuff.
Hi Peter, your setup looks great (and intimidating). I have encountered a couple of difficulties, though.
1) I've prepared my data trees as you indicated. When I connect the 'from' things seem to work okay (my 'from' points connect to your random 'to' points). But when I try to connect my 'to' data tree to 'toDTUser', everything fails.
2) Even when I connect my 'to' tree successfully, only 1 line is generated from each 'from' to its closest 'to'. Whereas it should have the number of lines equal to its actual connections number. Having the same number of lines as the number of connections is important for my next step. I'd like to have a distinct set of 'to' and 'from' point connections as outputs for A and B 'Line' component inputs but I don't see any way of doing this. I've attached an example image of what I'm talking about.
3) For some reason when my 'to' tree is connected, only the 'closest' mode works and 'random' still fails.
Thanks again, and apologies for my struggling to understand how this works!
Andrew
Oh, here's your GH file with my inputs.
OK, I'll investigate that ASAP
Er ... no internalized data arrived here (and the attempts is double in one "try").
Can I have 2 INTERNALIZED from/to datatrees please? - or 4 lists and I'll do the "merge" thingy (BTW: the code comes with an 123 seconds unlimited user satisfaction ... blah blah. Is quite impossible to fail IF (and I say it again: IF) the trees are properly made).
Hi Peter, sorry about that. Here's the Rhino file with the point data. I just randomly placed the points in this example.
Fotiadis ACME Industries Customer Care Dept reworked your def (your points, that is), cleaned some weird stuff, deleted numerous weird components (why they were there?) ...
... and here's the new/improved def (spotless/faultless/issueless/etc etc).
WOW: An added 345 seconds unlimited user satisfaction guarantee is offered with this code (at extra charge).
best, Lord of Darkness, Shah of NoMansLand, Prince of Whatever
Hi Peter,
It's an awe-inspiring thing I'm seeing. I can only humble myself in front of it.
Yes, I certainly need to learn the art of 'elegance' in GH.
I just have two final (I think final) questions.
1) My 'to' capacity supports 90 lines and my 'from' attempts exceed that, so there should be 90 successful line connections (or so, I guess, depending on the random seek attempts), but it shows that there are only 16 lines. Or maybe I'm missing where this output data is :/
2) As a final output for this script I want to have a simple way to connect all of the (90 in the current case) connections able to input into the A and B inputs of a simple Line component, so that A would be the 'from' points and B would be their corresponding 'to' points. I'm probably missing it but I don't see how to make this connection. My attached file explains basically this.
It looks beautiful, I have to say. And elegant. etc., etc.!
I'm looking forward to showing you the finished product.
Andrew
My dear Watson
1. The Dark Option (Matrix: plan C: the black pill) is one way ticket to hell > better stay away > hire someone to do code for you > be a happy bunny > stay away > we live once > be a happy bunny > stay away > ...
2. I've already explained why this 90 (or whatever) > 15 (or whatever) happens ... but ... er ... due to some communication "noise" (he he) I've added a flag that does smart (distinct) and stupid (!distinct) stuff. Visually inspect both ways and enjoy the art of pointless.
3. This wish of yours (duplicates) ... er ... hmm ... are you after fabricating data? (BTW: this is The Noblest of Arts, he he).
Lord of Darkness
Oddly def attached is omitted
Welcome to
Grasshopper
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
Added by Parametric House 0 Comments 0 Likes
© 2024 Created by Scott Davidson. Powered by