PDA

View Full Version : Updating a progressbar from inside a loop


harefort
12-10-2009, 06:14 PM
Hey guys!

I'm working on a small tool with some heavy ray casting and I want to add a progressbar to the UI so the user can see whether he should wait or go grab another coffee.

The issue is that setting the value inside the raycasting loop of the function will not update the displayed progress until the loop is over.

How can I update the progressbar at timed intervals or per loop interation?

Cheers!
-Sascha

harefort
12-10-2009, 06:37 PM
Ha!

My bad ... looks like I forgot to convert to float before dividing.

Varinderll
12-11-2009, 05:16 AM
2 possible conditions...

1 >> if the for loop is incrementin using an integer


rollout eh "eh?" width:162 height:103
(
progressBar progress_y0 "" pos:[7,31] width:148 height:8 color:(color 0 255 0)
button btn1 "progress Y0" pos:[16,56] width:128 height:24

on btn1 pressed do
(
if progress_y0.Value != 0 then (progress_y0.Value = 0) else (
for i = 1 to 300 do
(
progress_y0.value = 100 * i/300 --Simple old shool formula for calculating precentahe y0.
)
)
)
)
createdialog eh


2 >> If the for loop is incrementing using some objects in the scene


rollout eh "eh?" width:162 height:103
(
progressBar progress_y0 "" pos:[7,31] width:148 height:8 color:(color 0 255 0)
button btn1 "progress Y0" pos:[16,56] width:128 height:24

global i = 0

on btn1 pressed do
(
for geo in selection as array do
(
if i != selection.count then
(
i += 1
if progress_y0.value != 0 then (progress_y0.value = 0) else (
progress_y0.Value = 100 * i/selection.count
)
)
)
i = 0
)
)
createdialog eh


--sorry for my bad english -lol. :)

CGTalk Moderation
12-11-2009, 05:16 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.