Hi,
I was wondering if there is any component that can ‘collapse’ multiple lines into a single line. I can imagine doing it manually by exploding each line and measuring the point’s coordinates along the collinear axis and then joining the first and last point. This works for now however I can’t help but feel that there is a better way to do this.
It is okay to use in this situation however in order to use this definition, I need to first group lines by collinearity which can get annoying to figure out.
collapse_lines.gh (12.6 KB)
This component seems to only be for a segmented curve. In the example I have posted above, there are 4 separate lines. Putting them into simplfy crv just gives the same 4 curves back again
The lines in your example overlap. If you know that they’re all colinear, you can use the Fit Line component. It does not require sorting the points.
2 Likes
Thanks this sounds great! To use this, I still need to first segregate lines which are not touching each other.
In this example. I have a bunch of lines. I can segregate them by collinearity by measuring an angle with the x axis in the world XY plane. However, I still need to somehow sift the lines into branches based on whether they are touching each other or not. If I run fit line on this it will give me a whole line instead of ‘collapsing’ the two apparent lines formed by multiple overlapping lines.
detecting_touching_lines.gh (11.3 KB)
@Kyuubimode is that what you were looking for? I first check if they intersect is, if so I check if they have the same direction and create branches accordingly.
detecting_touching_lines_cs.gh (6.4 KB)
1 Like
Yes this is exactly what I was picturing when talking about a ‘collapse’ lines component. Grouping collinear touching lines and then using fit line makes sense. I tried testing your script with some more lines and it fails sometimes. Would you be able to look into this?
detecting_touching_lines_cs_test1.gh (10.2 KB)
This should be a bit more robust
detecting_touching_lines_cs_test2.gh (7.3 KB)
Maybe you still need to adjust the tolerances depending on the project
Thank you so much, this gives the required output!
1 Like