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