MAXScript Tools and Interaction with 3ds Max > Creating MAXScript Tools > Scripted Utilities and Rollouts > Rollout User-Interface Controls > Rollout User-Interface Controls Types >

# ProgressBar UI Control

User Interface Controls > Common Properties > Layout > Types > Progressbar

| Creating User Interfaces - Quick Navigation

A progressBar control is used to place a progress bar in a rollout.

The syntax is:

    progressBar <name> [value:<number>] [color:<color>] [orient:<name>]

The default alignment of progressBar items is #left .

Parameters

    value:

The initial progress percentage value (0 - 100). The default value is 0. This is an Integer value.

    color:

The color of the progress bar. The default color value is [30,10,190].

    orient:

Specifies whether the progress bar should fill from left to right ( orient:#horizontal ) or bottom to top ( orient:#vertical ). Default value is #horizontal .

Properties

    <progressbar>.value Integer

The progress bar complete percentage (0 - 100).

    <progressbar>.color Color

The color of the progress bar.

    <progressbar>.orient Name

The orientation of the progress bar fill: #horizontal - left to right; #vertical - bottom to top.

EXAMPLE:
     --define a rollout
    rollout progressTest "Progress Test"
    (
    button doit "Process Scene" -- button to start processing
    progressbar doit_prog color:red -- a red progress bar
    on doit pressed do -- when the button is pressed...
    (
    objArray = geometry as array -- get all geometry objects into array
    for i = 1 to objArray.count do -- and iterate through all of them
    (
    -- update the progress bar percentage -- for example, if there are 20 geometry objects -- and i is currently 1, you have 100.0*1/20 = 5% -- when i is 2 you have 100.0*2/20 = 10% etc...
    doit_prog.value = 100.*i/objArray.count
    -- do something with the objects, like printing their names
    print objArray[i].name
    )-- end i loop
    doit_prog.value = 0 -- when ready, reset the progress bar to 0%
    )
    )
    createDialog progressTest 200 60 -- create a dialog to test

Note

The .value property requires an integer between 0 and 100. When calculating a percentage from a current value and a total value, the order the values are multiplied and divided does matter!

Dividing them first and then multiplying by 100.0 would always return 0.0 because an Integer divided by an Integer yields an Integer, and since the result is less than zero, it is rounded down to zero:

    1/20*100.0 -> 0*100.0 -> 0.02/20*100.0 -> 0*100.0 -> 0.03/20*100.0 -> 0*100.0 -> 0.0

but

    100.0*1/20 -> 100.0/20 -> 5.0100.0*2/20 -> 200.0/20 -> 10.0100.0*3/20 -> 300.0/20 -> 15.0

When starting with the Float value 100.0, the final result is implicitly converted to a Float because a Float multiplied by an Integer returns a Float, and a Float divided by an Integer still returns a Float. The Float value is then converted internally to Integer when assigned to the .value property.

Events

    on <progressbar> clicked <arg> do <expr>

Called when user clicks on the progress bar. The <arg> argument will contain the percentage value at the clicked point.

This event handler makes the progressbar an interactive UI control. See How To ... Enhance the Morpher Modifier With Floating Controls for an example of progressbar usage as slider replacement.

    on <progressbar> rightClick do <expr>

Called when the user right-clicks the Progressbar control.

Available in 3ds Max 2010 and higher.

#### See Also

- Rollout User-Interface Items Common Properties

- Rollout User-Interface Items Common Layout Parameters

- Rollout User-Interface Control Types

- Progress Bar Display