# How can I round the length of each line

Hello guys thanks for your help.
I need to round the lenght of each line to the nearest 0.05

For example if I have this value 0.464326 (which its the lenght of the line) and how can I convert it to 0.45 lenght?
I have a whole bunch of lines that I created but I need to round them all. I am attaching the def and the rhino

I do not need to round the text panel, but I need to round the lenght of each line.
The lines are created by 2 sets of points I might need to modify the position of this points?

question.3dm (825.0 KB)

question.gh (71.8 KB)

I don’t do Grasshopper but in my Python code I’d use:

value = 0.05*round(value/0.05)

Regards,
Terry.

Have a look at this:
question_re.gh (75.4 KB)

OMG you are the man! you totally saved me.
Thanks!!!

Perhaps you meant 0.446325 to 0.45 - that would be rounding and not reducing the length. You’ll have to use `x = round(x,2)`

if you have to 0.464325 to 0.45 - that is change of the value `x = 0.45`

if you want to cut the length of the of the value without rounding it has to be `x = float(str(str(x)[:-4]))`

If interested Pufferfish has a bunch of Rounding components, and if you wanted the lower end of the rounding like you say 0.464326 to 0.45 you can use the T input of the rounding components and set them to Floor.

1 Like