Break!

Is there a plan to add Ctrl + C or something so I can break out of my code without Dyno and Revit crashing every time I use a while loop but forget to add a count?

Please say yes! :smiley:

1 Like

Noā€¦ consider it punishment for forgetting to add the break clause! :stuck_out_tongue_winking_eye:

4 Likes

haha! Noooooooo :cold_sweat:

4 Likes

No fair!!!
/me sulks

2 Likes

Weā€™ve all been there before. I have a tab in notepad++ always open and a counter based while loop is one of many starters in it. Suggest building an onhand reference like this, saves me much time.

1 Like

Typically I find that if I need a while loop, Iā€™m likely doing it wrong.

For loop? Often.
List comprehension? No worries.
While loop? May not be the best way to go about what Iā€™m after, so confirm itā€™s a necessary effort.
Still need that while loop? Save often, build the ā€˜stopā€™ clause first, and expand from there.

3 Likes

Also well placed continues and breaks within the loop can also make your overall code more efficient as well as an exit on fail.

1 Like

Haha, thanksā€¦ Not helpful :stuck_out_tongue:

Sometimes I want a while loopā€¦ They exist for a reason no?

Gimme a break :laughing:

I want that breakā€¦ even more than I want autodesk to sort out the broken date format :stuck_out_tongue:

Yep but I mean hitting the ā€¦ get me out of here ā€¦ key when Iā€™ve messed up my code and itā€™s gone into an infinite loop.

Oh, the ā€œget me out of hereā€ key! You should have said so earlierā€¦ Looks something like this ( design and location varies per device model though) ā€¦

3 Likes

Unfortunately thatā€™s trueā€¦ But I want, nay demand a more user friendly one :laughing:

I still think that should be marked as the solutionā€¦ It is technically what you wanted! :stuck_out_tongue_winking_eye:

2 Likes

hahaha!!! Am actually laughing! :joy:

1 Like

One other thing I have used in some scripts recently is nodes to basically send all or nothing, I call them Resistors but there is probably a formal name for this process (gates?).

They warn a user if they are about to send more than a certain number of objects into a script and give you the option to send nothing if you hit cancel. Might help in some cases, hereā€™s a rudimentary example using Python, I use them in pyRevit typically to terminate script runs if users run a script that has the potential to get way too many objects.

Resistor.dyn (8.5 KB)

1 Like