 # Scale a closed Curve and the Lengths between control Points

Hello everyone.
I am trying to scale a closed curve (with only 90 degree corners) and the lengths between the control points of this curve to a specific length. I already achieved that the length of the curve is a multiple of the number slider.
Additionally I added a second number slider to control if the new curve should be larger or smaller than the starting curve.
My problem now is that i dont know how i can scale the lengths between the control points to be a multiple of the given length. I think galapagos could be a solution for that?

Scale Curve to Length.gh (9.5 KB)

You need to internalise your curve if you intend to get help here…

https://discourse.mcneel.com/t/help-us-help-you/50034

i have internalised the curve now.

Scale Curve to Length_02.gh (9.9 KB)

It needs some reworking i think, but it might help…
Anemone used.

Scale Curve to Length_RE.gh (22.3 KB)

Thanks.
But with your solution the whole curve is scaled by the length of the bricks.
As you can see on scetch my goal is that i have a starting curve/first curve, a scaled curve were the length is a multiple of the brick length and a final curve.
The final curve should have the same length as the scaled curve but the different lengths between the corners should also be a multiple of the brick length. (according to the proportions of the first curve)

I think that there are different solutions for every curcve possible (-1, +0, +1 brick length) and maybe the closest solution can be found with galapagos?
but how can i generate the final curve?

Has anybody else an idea how to solve this?

Hi Lukas
I did this whith C# component, but I don’t know if it’s what you mean？

Scale Curve to Length-Tc.gh (9.2 KB)

I think the main obstacle stems from handling the whole logic starting from the final perimeter of the polygon because your angles are always 90 degrees, and because your polygon is closed, if you represent its edges with vectors starting from a random corner, proceeding clockwise/countercloskwise, you end up with something like this:

in my mind, approaching this problem “outside → in” (starting from the perimeter and getting its edges) is infinitely more difficult than approaching it inside → out (starting from the edges and getting its perimeter)

the final perimeter is just the mass addition of the length of all the edges, but all the edges must “be able to exist” before being counted in the perimeter: for an edge to exist, it must be multiple of “brick length”

not all perimeters can exist by following this rule: bricks must always be even, you add two or you remove two because the polygon must be closed, so you perimeter will increase/decrease by a minimum of (2 * BrickLength)
if brick length = 5, you will always end up with a closed polygon with 90° angles with perimeter value multiple of 10

you can chose the approximation of the edge length transformed into bricks by using the math you prefere

here is by using integer division, so the perimeter made of bricks will always be equal or smaller (even much smaller) than the “plain scaled” perimeter

or you can use something like Round → Ceiling to always get a higher result

or Round → Nearest (this also has the right color preview as in your sketch)

Polygon_in_Bricks.gh (23.6 KB)

Thank you !