Running time for a while loop inside an imperative block

Hi.

I’m very new to Dynamo for Revit and recently I’ve tried to make a while loop inside an imperative block the following input values used to create the loop.

My problem is that the running time is about 30 seconds, and when the imput values are lists containing 8 items each, the running time is about 8 minutes long.

I usually use Mathcad for such while loops and they only take 1 second to run. I’ve also tried to make a pythin script node with the same loop inside it without help.

Finally, I’m aware of my messy definitions inside the loop and the small increment (0.001), but since it’s possible to run in Mathcad I think I’m something very important when creating the while loop in Dynamo. Has anyone encountered this problem before?

Without trying to understand your math in the code block. What do you want to achieve?
It is very rare you have to use loops in dynamo. Maybe there is a better way to do what you want to do.

2 Likes

Yes, as you say I shouldn’t use these kind of loops at all in Dynamo. The reason why I want to use the loop is to create the gaps between diagonal and the vertical members for multiple trusses, like in the picture below. When the y-coordinate of the diagonal member end nodes is offset, the angle and the gap in the other end i changed. But making a loop which offsets the two end nodes until the gap = 15mm is reached, the coordinate of each end node can be found.

I think it’s too time consuming to try to offset the nodes manually in Revit, especially with multiple joints with different member sizes etc., and therefore I want Dynamo to model the trusses automatically. The steel connection add-in in Revit 2018 doesn’t offer welded connections with a gap setup. I’m also limited to only use Revit 2018, even though Autodesk Advance Steel and Tekla might offer a joint setup I need.

It would really be helpful if Dynamo could read the loop somewhat faster.

Which gap are you talking about? It is not really clear.
If it’s about this distance there are probably many solutions out there other than a loop.
2020-05-03 17_00_53-Running time for a while loop inside an imperative block - DesignScript - Dynamo

In fact you can do it with 5-6 nodes only.
Rotate a series of members on the centerpoint of the diagonal member. Use the doesIntersect node to check which one does not intersect the vertical members. Get the first False item from the list with List.FilterByBoolean
2020-05-03 17_05_12-Running time for a while loop inside an imperative block - DesignScript - Dynamo

Thanks for the reply. The distance is actually between the webs of the profile of the members as in the picture below (gap, which is 15.1703mm).

I see your point, but then I would need to try a dozen of angles and points along the center axis of the diagonal, since the trusses will have different sized vertical members between the diagonals. The chords above and below the diagonal might also have different sizes (profile heights). Then, if the lower joint has the right gap of 15mm I also need to verify that the upper joint has the same gap.