Dispatch lines based on equality with many z coordinate values


I would like to separate a lot of lines into 2 groups:

  • the line’s midpoint has a z value equal to any of the values written into a panel
  • the rest of the lines

With cross reference I managed to solve the first part, but the false values are still not the ones I would like to achieve.

The problem is that these are discrete z values, not a range, and I don’t know how to test the line midpoints for them at the same time without many OR gates.

GH file:

Group_based_on_Z.gh (18.6 KB)

Thank you!


The seven values in your panel don’t include all of the possible values of ‘Z’ in your data:

Yes, that’s the point, from all the possible values I would like to separate the ones on the panel list and the ones that are not part of it.

It could work with a true/false pattern, the problem is as I had no better idea I had to use a cross reference which messes with the false values.

Is this what you’re looking for?

Group_based_on_Z.gh (23.4 KB)


Group_based_on_Z_2012Feb18a.gh (23.0 KB)

You can add PShift (Shift Paths) to the Dispatch outputs to restore the original tree structure.


Thank you for your work, this is the solution I was looking for!

I personally prefer Joseph’s one !
I’d just add shift path at the end to retrieve the same datastructure as the begining.

My solution starts by flipping the tree, so the lines are by level (and not by rows).

It just depends on what you need to do from here !

I tried to implement Joe’s solution in my original code but, unfortunately it didn’t give the right true/false values for me with MM. (not really sure why, Similarity didn’t work either)

I need the original data structure, so I left out flipping and cleaning the tree (only graft + shift at the end) and it works just like I wanted! (had to use ‘similarity’ there also as ‘equality’ was missing some lines)

So at the end I used a hybrid solution, but thank you for suggesting MM/MA, I didn’t even think about it! :slight_smile:

That lost me right at the beginning!

Well… It works with the data you presented and makes sense to me so what can I say? You must have missed something.

Did you graft the output of Clean Tree at the beginning?

Did you see my comment about adding PShift (Shift Paths) to the Dispatch outputs to restore the original tree structure?

Yes, it worked perfectly in this small code for me too, however when I implemented it in my original, bigger code it didn’t work the same (I couldn’t find out why, it has to do something with decimal places, but Similarity should have solved it )

It is a mistery why it works different, because I internalised the lines from the bigger code.

Anyways, it is working now, so thank your for the help Joseph!

Where there’s mystery, there is no mastery.
– Yogi Bhajan

1 Like

If you have LunchBox use sort duplicate values

Group_based_on_Z2.gh (24.9 KB)

I don’t. The pattern of lines in your image is not the same as what @antoinemaesantoine and I got. We used different methods but got the same result, by appearance at least.

I asked him about Lunchbox.
It is not a problem the pattern can changed instead of serie or another method by joining all lines to reduce points and calculation


I didn’t know this component (I don’t use Lunchbox), but a good idea, thank you for sharing it!

1 Like

If your goal were to filter alternate lines, as suggested by @seghierkhaled’s first post, you could do this:

Group_based_on_Z_2020Feb19a.gh (19.6 KB)

This avoids the issue of matching Z values to a list while allowing for an arbitrary tolerance.