I need help about rounding error on Dynamo

Hello everyone. I am trying to create a parametric truss. While arranging number of vertical struts I am facing a problem. Here for these number it works fine and it gives me the panel width correctly


but when I change the length to the number which are not dividable by 3

it is stopping the iteration before reaching the length of truss. How can I solve this problem ?

If you think about it in terms of curve segment lengths it might make a little more sense. The sequence is essentially saying 0 is the starting point and L is the ending point of the parent curve. If you break that into segments that are L/n units long, the values you get in return are the starting points of those equal length segments. So in your example, the last segment starts at 3.33 but extends beyond the total length of the parent curve so there’s no point after. Landing on the final “length” of the parent curve (L) would give you the last possible point.

What you’re actually looking for will determine how this needs to be handled. If the curve is not divisible by the number of segments you want then you won’t have equal segment lengths. It seems like you just want to ensure that the curve is always capped at the end, which needs to be dealt with separately. One option would just be to add the final length to the end of the list and then return the unique values to ensure you don’t have a duplicate in the case of a divisible curve length.

2 Likes

hello


cordially
christian.stan

3 Likes

Thanks a lot.

1 Like