[Closed] Progressbar update in function
I seem to have a recurring problem where if I have a progressbar update in a function then this will fail the first time I run the script (undefined) but will work on subsequent attempts.
I assume this is because when the the script is run for the first time the function is declared when the progress bar has not yet been intialised?
Whats the solution?
Thanks
have you declared it as a global variable/function? can you do a check like:
if progressbar != undefined then …yadeyadeyade
I had this same problem a while back, and one solution was to predeclare your rollout variable as global, like such:
global myRollout
include "someFunction.ms"
include "someOtherFunction.ms"
rollout myRollout "My Rollout"
(
etc.
)
You probably have something like
rollout rlt_Progress "Progress"
(
rlt_main.pbar.value = 100/i --foo
)
rollout rlt_main "Test Rollout"
(
progressbar pbar "till completion"
)
And your code is getting to the rollout rlt_Progress and since it hasn’t seen rlt_main yet it is undefined.
But the code will execute through that and rlt_main will be declared as a global variable after that, meaning upon next execution the global variable rlt_main will exist and will execute properly. (Variables in Maxscript are global unless declared otherwise and will persist through resets/file-opens etc till max is exited.)
To fix these problems explicitly declare your rollouts and functions at the top of the file
global rlt_main
global rlt_Progress
global fn_function
etc.
Just as the above poster said