Asking for help, question of array

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

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)

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?

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

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.

thanks David again!

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)

1 Like

David,you are so great!

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.

1 Like

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

thanks!