The built-in progress bar in max status bar is not suited for every task, and as I have found myself writing quite similar lines of code to print debug info to the prompt and trying to prevent max window from 'not responding' over and over again, I whipped up a little struct to make it easier.
_timeSpan = (dotNetClass "TimeSpan").FromSeconds
_info = stringStream "",
_start = timeStamp(),
fn update counter =
seek _info 0
format infoFormat counter to:_info
if mod counter 10 == 0 do
fn end =
pushPrompt ("DONE, time elapsed: " + (_timeSpan ((timeStamp() - _start)/1000)).ToString())
The custom "infoFormat" string contains anything you want to be kept informed of, like
"Intersections found: %" or
"Filtering: % of 1000". Calling the end function is purely optional, nothing serious happens if you don't do it, only the total amount of time will not overwrite the last value the update function was passed.
For 3ds max versions earlier than 2011, the
windows.processPostedMessages() obviously won't work, you can use
(dotnetClass "Application").doEvents() instead, as discussed for example here. Calling it on every value which is divisible by ten is arbitrary and based on where it is called from might not happen at all or might happen all the time so make sure to keep that in mind and feel free to modify it (as well as the whole struct) to suit your needs.
An artificial use case scenario looks basically like this:
local totalCount = 100
local progressInfo = progressInfoDef infoFormat:("Processing: % of " + totalCount as string)
for i = 1 to 100 while NOT keyboard.ESCpressed do
DISCLAIMER: All scripts and snippets are provided as is under Creative Commons Zero (public domain, no restrictions) license. The author and this blog cannot be held liable for any loss caused as a result of inaccuracy or error within these web pages. Use at your own risk.