Python script called as a process (RedirectStandardOutput = true): Progress bar printed on multiple lines



The Rhino Plugin I’m developing calls up a python script using system.Diagnostics.process(). I’m catching standard outputs and writing them to the rhino command using RhicoApp.WriteLine(event.Data). Everything worked fine until I decided to add a progress bar inside one of the script’s iterative loops (it is a good feedback for users). Obviously, since I’m redirecting outputs with WriteLine(), at each iteration, the progress bar’s status gets printed on a new line, which is really not ideal!

What would be the best approach to call that script and have it’s outputs printed as it would in the console?


P.S.: I’m calling the python script inside a packaged python interpreter that contains libraries needed for the script to work. This is for portability and distribution; I am not using the native python scripting tools of Rhino.

(Steve Baer) #2

There are ShowProgressMeter, UpdateProgressMeter, and HideProgressMeter functions on RhinoApp that may help.

(Willem Derks) #3

In addition to the Steve’s suggestion you could also update the prompt insted of writing to the commandline:




Thanks @stevebaer and @Willem for the quick response. Weirdly enough, the progress-bar I use (tqdm) prints to the stderr stream by default. This is enough for me to catch those separately and print the stdout using WriteLine() and stderr using SetCommandPrompt(). This way, outputs other than the progress bar still get printed in the command window (leaving some sort of history) and not just the command prompt.