I’m trying to sort a list of families by location. First sort by z then group, then sort those groups by y then by x.
I’ve gotten as far as sorting and grouping by z, then sorting the groups by y. I’m not sure how to continue and sort them by x without losing the y sort I already did. One way would be grouping them again by Y, but I tried that and ended up in sub-list hell. Any suggestions?
Oh, and I also found a sort points by XY node (as seen in the screenshot), but I’m not sure how I can use it.
I did search the forum. My node setup was actually partially inspired by this post.
In your example they used a sort by function, which I am not able to use since I’m using separate components of location points (x,y, and z), and not the family instance location function itself.
My problem is that when I sort by y, then try to sort the result by x, the y becomes scrambled again.
Below is the continuation of the above screenshot.
However, in my case, since my goal is not to sort the list itself, but sort another list by keys, I’m not sure how to use the code you suggested? I guess one way is to store the 3 lists of point components into variables and then use those variables as keys for the sort argument. I don’t know if that would work though, and I can’t try it out myself because I don’t know python.
Hmm, I tried your script, but it’s still not sorting the X at the end for some reason. I flipped the itemgetter(1,2,3) to itemgetter(3,2,1) since I want to sort by Z first and X last.
It sorted by Z then by Y but failed to sort by X, as you can see in the screenshot below. What do you think is the reason?
The reason why the rounding “helps” is that your points without rounding is actually not all the same "location in the Y point, it is just an inaccuracy beyond 3 delimiters…
This is without rounding (sorted Z,Y,X) and as you can see it is in fact correct (as Y beats X). Though with 3 delimiters it looks wrong. The rounding combats that
Please read and copy carefully. It is spelled clr not crl…
Also basic troubleshooting skills. The error is on a specific line so double check that line before asking for help.