ProgressBar stalling in WIP

python

(Willem Derks) #1

Hi,

The attached python script displays an issue with the progressbar stalling.
It’s a dummy script where after about 33% the progressbar stops responding and only when the script finishes there is a redraw.

In V5 the progress bar runs fine until the end.

import Rhino

def DoThis():
    sphere = Rhino.Geometry.Sphere(Rhino.Geometry.Point3d(0,0,0),50)
    VMP = Rhino.Geometry.VolumeMassProperties.Compute(sphere.ToNurbsSurface())
    

def TestRun():
    #Initialize progressmeter
    count = 1000
    label_string = '{} part breps are being prepared'.format(count)
    Rhino.UI.StatusBar.HideProgressMeter()
    Rhino.UI.StatusBar.ShowProgressMeter(0,count,label_string,True,True)
    progress = Rhino.UI.StatusBar.UpdateProgressMeter
    P = -1
    for p in xrange(count):
        P+= 1
        progress(P,True)
        DoThis()
        
    Rhino.UI.StatusBar.HideProgressMeter()

    
TestRun()

progress_test.py (667 Bytes)


(Dale Fugier) #2

With each iteration, call RhinoApp.Wait() so Rhino’s message queue get’s pumped.

Does this help?


(Willem Derks) #3

Hi Dale,

Yes this prevents the stalling.
However, in V5 the stalling does not occur and it feels if such a Wait is needed,
the UpdateProgressMeter is not working as it should.

From my point of view it should be that calling an update on the ProgressMeter would not require me to initiate another wait.

Or am I spoiled thinking this should work regardless the Wait()

-Willem


(Dale Fugier) #4

Well, Rhino 5 does the ‘Wait’ for you. Be we removed this from Rhino 6, as it isn’t always and, thus, could cause issues when called from another thread. So we wanted to make it the caller’s responsibility.

– Dale


(Willem Derks) #5

Hi Dale,
Thanks for the explanation and insight I see the need for removing it.

-Willem