I have a list of vectors taken from a room outline (in purple). I only want 1 instance of each vector. I also want to remove any vectors that are parallel to each other.

I’ve tried it several ways, all pretty contrived. This is the best one so far, but still hideous. Can anyone improve this please?

Making sure I understand this right, the result of pruning the parallel vectors would mean that the three non-endpoint dots in the bottom left would be simplified to one vector?

List.UniqueItems should work on a vector list.

EDIT: Huh. Learned something new (apparently it doesn’t). You can convert the vector list to a string list first before running List.UniqueItems.

It’s a rectangle room with one angle.
So one for the lines on the x-x axis, one vector for the lines on the y-y axis and one vector for the sloping angle line.

It didn’t for me (this workstation has an outdated build of Dynamo), but I see that the source information was the room finish boundary. I believe the vectors for the lines generated from that node all point ‘outward’, in which case you will need to address opposing vectors for parallel lines.

1.Vector.Reverse the list.
2.For the original list AND the Vector.Reverse list, generate lists of their angles about the X-axis.
3.Only take the indices from each list where angle<180.
4. You now have a modified list where vectors have been adjusted to only be within Quadrants 1 + 2 of the XY plane.
5. You should be able to do the ToString+UniqueItems workflow from here.

Frankly, if your method logically works (your division method is doing the same quadrant check as the angular method) and doesn’t hang up from resource load, it can be as hideous as it wants to be. It still works =P. The route I proposed takes up more screenspace and isn’t addressing any logical faults yours might have.

If your concern is other users interpreting the script, annotate it up for clarity before deploying it.

And as @Robert_Younger mentioned, while it’s good to learn the more efficient ways to get what you want, it’s totally fine to have a lengthier process as long as it works for you.

Correct. It gives you the grouped parallel vectors. From there you can just pull any one vector from each group. If the specific vector doesn’t matter then you can just pull the first item. But if you want something like the normalized positive vector then you’ll have to do some sorting first.

Think the Vector.AngleWithVector could cause issues as it is the narrowest angle in both cases, so an angle of 45 degrees could mean (1,1,0) or (1,-1,0).

Vector.AngleAboutAxis removes that issue of my recollection serves right. You have to subtract 180 from values >= to 180 though.