Asking for help, question of array

unhandled

(C18957181678) #1

I want to compare each value in an array (such as the value A) with other values in the array. When a value B in the value is the same as a, then when the value after A is compared, B is excluded from the array value. B does not participate in the subsequent numerical comparison, how to write GH

thanks


(Tim Stark) #2

(C18957181678) #3

In the attached file, I want to find the closest parallel line within a certain distance. After one line matches another line, the line will no longer participate in matching.
wall_up.3dm (224.8 KB)


(David Rutten) #4

That’s not even remotely what “the same as” means.

Question; if line 6 was compared first, it would have matched up with line 5 and 5’ would have matched nothing. I’m assuming that’s not a result you’d be happy with. If you make your comparison more complicated to only include line segments that -when projected onto each other- yield a non-zero overlap, then segments 6 would have matched with segment 5’, to the detriment of segment 5. I’m assuming this, too, is a result you don’t want.

So what is the exact comparison algorithm supposed to be?


(C18957181678) #5

thanks david.
I want to create a rule:

  1. The longer line will have the first priority to match other lines
  2. The vertical projection of line 1’ on line 1 should overlap on line 1
  3. When the distance between straight lines exceeds 300, no match will be made

(David Rutten) #6

Ok that to me sounds like an unambiguous algorithm. It’ll require nested looping over the collection while modifying the collection, which means barring plug-ins like Hoopsnake or Anemone it can’t be done without custom scripting.

I can have a quick attempt at C# to see how far I get, but no guarantees.


(C18957181678) #7

thanks David again!


(David Rutten) #8

Not quite there yet, partly the line data is not clean enough, and partly we still need more rules because sometimes the wrong segments are paired up: pair_finder.gh (28.6 KB)


(C18957181678) #9

David,you are so great!


(David Rutten) #10

If you come up with a rule #4 and maybe #5 I can adapt the code, but you’ll need to look at your data in some detail first I imagine.


(C18957181678) #11

It has done.
when first line was matched, the loop need to stop, so add “break” in line 107, The results are correct.

thanks!