Aleksandr Pankin, Senior BIM manager asked me on LinkedIn if I can help him with a ProgressBar for Dynamo I have posted a long time ago. This is an old piece of code that I originally took from this article of The Building Coder. The free .dll has been shared a while back when I was working with designtech. Since I no longer work there and designtech no longer exists, the piece of code has been lost. Here, I have collected the pieces back together as these are still useful to people out there.
Python
The implementation of the ProgressBar is quite simple. You can find a sample code below. The tricky part is adding a reference to the .dll. IronPython messed up the old way of referencing, so that has now changed to ‘clr.AddReferenceToFileAndPath()’.
# @didonenov
# Load the Python Standard and DesignScript Libraries
import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Add reference to the ProgressBar.dll
path = IN[0]
clr.AddReferenceToFileAndPath(path)
#clr.AddReference(path) # old format
from AdnRme import ProgressForm
rooms = IN[1]
result = []
iterations = len(rooms) #T his is the counter for the ProgessBar
# Implementation
def Main():
with ProgressForm('Message you want to display',
'Processing {0} elements ...', iterations) as form:
for room in rooms:
pass
if form.getAbortFlag(): # The user can Cancel the long process
return 'Aborted by user.\n(Freeze/Run/Unfreeze node to proceed)'
form.Increment()
message = Main()
# If we failed to run the process, report
if message:
OUT = message
else:
OUT = 'Successfully populated %s elements' % str(iterations)
OUT = 0
Download
The links provided below are from GitHub. I hope that source stays alive longer this time around.
You can download the ProgressBar.dll and a sample Dynamo definition from GitHub.
Leave a Reply
Want to join the discussion?
Feel free to contribute!