Curve Optimization / Spline to Arc+Line

Hi everyone,

I have a lot of curves that need optimization and manual process would take too long. Can anyone advise on how to approach the idea below? Any ideas would be greatly appreciated!

  1. I would like to make a script that redraws a curve into arcs&lines (or polyarcs) without any kinks, while trying to stay close to the shape of the original curve.
  2. Additionally, it would be great if there is a way to make a parameter that would balance the # of curves-VS- staying close to the original curve. Example of such parameter:
  • value 1 = optimized curve almost identical, but consists of 200 arcs&lines
  • value of 0.2 = optimized curve diverts from the shape, but consists of only 10 arcs&lines

Here is an example of a curve to optimize:

And example of optimized curve:

3D file of the screenshots above:
Curve for cleanup.3dm (96.1 KB)

Here’s my best attempt so far, not quite what I’m looking for yet:

GH definition:
Curves.gh (14.8 KB)

That’s rather hard without code. If you are familiar with C# (level required: mid to advanced) I could provide some hints on that matter (but not the solution: strictly internal stuff).


On the other hand … If I remember correctly someone has posted a solution some time ago … but I can’t recall any detail.

1 Like

Thanks for replying Pfotiad0! Unfortunately, I’m not that skilled with C#.
If you can think of a high level approach/tips that would help as well.

This definition is using a python script I found in the forum but I lost track where.

The input curve is internalised and I filleted all kinks and rebuilt the curve.

The result consists of arcs only.

curve_to_arcs_and_lines_python.gh (23.3 KB)

2 Likes

This is awesome, thank you!

To take it further, any ideas on how one might decrease the number of arcs that are similar radii?

for example:

Probably here:

:male_detective:

2 Likes

Anders, thanks for your reply!

I was just in a process of adding onto Martin’s definition:

  1. dividing the curve at the inflections points (pink)
  2. add the points located next to small radii (yellow)
  3. and then somehow group the radii in between the points (yellow and pink) and rebuild the curve.

I got to about half of the definition, not sure about step 3 yet, but it seems like it could work …?

I’m going to check out what you sent, it would be great if I could have lines as well