Sort lines by horizontal vertical and diagonal directions

Hi there,

I have a script that sort horizontal and vertical lines but not diagonal lines. This script i found on the GH forums and i want to sort/filter diagonal lines out cause of trusses i want to make in an structure. Is there anyone who can help me out here? The GH script is attached.

sortbydirection.gh (22.7 KB)

1 Like

Internalize curves or upload 3dm file.

sortbydirection.2gh.gh (47.3 KB)

sortbydirection.2gh.gh (50.8 KB)

2 Likes

Thank you very much!

I was looking for a definition that did this, found this thread, and then realized I needed a definition that was more universally usable, so I made one.

This one sorts line segments not by “horizontal, vertical, diagonal”, but by whether they’re parallel to the X, Y, or Z, axis (orthogonal) or whether they’re diagonal and parallel to the XY, XZ, or YZ plane, or whether they’re diagonal and go through all axis/planes (XYZ).

Also made it tidy and ready to cluster, and there’s internalized geometry for testing if you edit the definition- segments connecting all the vertices of a cube, joined randomly.

_SortLineSegmentsOrthoDiag.gh (28.9 KB)

2 Likes

This is awesome, I really needed this. Max with maximum intellect around here.

This was version 1, I think. It can be buggy in certain circumstances.

Here’s Version 2, and another handy sorter for orthogonal faces of solids (HT @HS_Kim for showing me the underlying concept for the second one.)

Ortho Sorters.gh (30.9 KB)

You will need to download sasquatch for version 2 to work. But version 2 is pretty much glitch proof, where version one often failed to correctly recognize orthogonal lines on edges of objects created using boolean union in rhino.

You should also look for the topologizer component elsewhere, and simplify curve. There are ways to put those together with my little sorter that eliminate all accidental bad inputs for feeding a number of types of definition downstream.

I am a newb and these clusters may very well do things that other components can already do, I’d love to know if I’m duplicating existing stuff.

3 Likes

oh sasquatch doesnt work in my grasshopper. Boolean is not involved in mine just few closed polylines so I guess wont be a problem with version 1

OK. Alternatively, use version 2, but open up the cluster and replace all instances of Sasquatch’s “document tolerance” with Panel components, into which you enter your document tolerance.

1 Like

I might use other methods!SortLine.gh (27.6 KB)

2 Likes

Hi everyone,

I know that this thread is old, but there is a simpler and easier way to do it.

Use “Vectors” math in the following way …

  1. From every desired line (or curve) extract its end points.
  2. Create a vector from the previous end points using “Vector 2Pt”.
  3. Measure the angle between previous step vectors and any other vector of your preference.

Thanks, ur script helped me a lot … Regards

Awesome script, thank you!