Optimize a path / straighten a path

#1

Hello,

I wrote a script to find the middle path in a room (i.e. a corridor in my case) and now I would like to optimize this path by straightening it.

The goal is to create ducts following the best path possible depending on geometrical constrains

I’m using the Voronoi node to get the “analogical” path but now I would like to get the fittest straight path.

Any suggestions?

#2

Use Springs.Line.StraightenXY:

2 Likes
#3

Could also look at engineering something using Line.ByBestFitThroughPoints, stopping at points which have three or more lines out of them.

1 Like
#4

It’s not working in my case but it was a good option, thank you !

#5

I’m note sure how to make it stops as you say, can you make an example or explain more specifically ?

#6

Get your Curve start and endpoints.
Flatten the list and group common points (list.groupbykey where the list and key are the same.
Discard groups with less than three elements in them.
Find which lines in the first list have those points in them. Those are the branching points.
Now you can start with those curves and use a group curves method to find the polycurve from each branch point.

1 Like
#7

All my groups contain only one item.
(i’ve checkd all of the list)
image

#8

Group the start and end points, not the lines. :slight_smile: