MAXScript Language Reference > Values > Time Data Values >

# Time Values

Value > Time Data Values > Time Values

| Values and Collections - Quick Navigation

The Time class implements animation time in MAXScript.

Time values reflect the properties of animation time in 3ds Max.

Resolution is in ticks, with 4800 ticks per second.

You can work with time as ticks, frames, h.m.s, or normalized time.

You can intermix numbers and time values in time computations defined below.

The rule is that numbers are always interpreted as frame counts, with floating point numbers specifying fractional frames.

The numbers are always converted to tick-based time values internally and so have an ultimate resolution of 4800 ticks per second.

You can do time arithmetic and comparisons using numbers as well as time values and convert between time and (frame) numbers using the as operator. See also Time Literals.

Literals

    [-]{<decimal_number>[m | s | f | t]}+

minutes/sec/frames/ticks

    [-]{<digit>}:{<digit>}[.{<digit>}]

SMPTE mins:secs.frame

    [-]<decimal_number>n

Active segment normalized time

Example Literals

    2.5s -- 2.5 seconds
    1m15s -- 1 minute 15 seconds
    2m30s5f2t -- 2 minutes 30 seconds 5 frames 2 ticks
    125f -- 125 frames
    17.25f -- 17.25 frames
    1f20t -- 1 frame 20 ticks
    2:10.0 -- 2 minutes 10 seconds 0 frames (SMPTE)
    0:0.29 -- 29 frames (SMPTE)

Constructor

    normTime <float>

Time from normal fraction based on the current scene animation range:

FOR EXAMPLE
    animationRange --check out the current animation range:
    (interval 0f 100f)
    theHalfTime = normTime 0.5 --get the middle of the range:
    50f
    animationRange = interval 42f 1024f --set new scene range:
    (interval 42f 1024f)
    theHalfTime = normTime 0.5 --get the middle of the new range:
    533f
    theTenth = normTime 0.1 --get the frame at 1/10 of the range:
    140.2f

Properties

    <time>.ticks

Time as ticks.

    <time>.frame

Time as frames.

    <time>.normalized

Time as normalized fraction of active segment (scene animation range):

FOR EXAMPLE
    animationRange --check out the current animation range:
    (interval 0f 100f)
    theHalfTime = 50f --the middle of the range:
    50f
    normalizedTime = theHalfTime.normalized --the normalized time:
    0.5

This is the inverse of the normTime constructor described earlier.

Operators

    <time> + <time>

Time values addition.

    <time> - <time>

Time values subtraction.

    - <time>

Invert time value

    <time> * <number>
    <time> / <number>

Scale time

    <time> == <time>

Compare time values for equality. Returns true if the two time values are equal, false if they are not.

FOR EXAMPLE
    if sliderTime == 42f then "It is time!" else "Not yet!"

    <time> != <time>

Compare time values for non-equality. Returns true if the two time values are not equal, false if they are equal.

    <time> > <time>

Returns true if the first time value is greater than the second time value, false if it is less or equal to the second time value.

    <time> >= <time>

Returns true if the first time value is greater or equal to the second time value, false if it is less than the second time value.

    <time> < <time>

Returns true if the first time value is less than the second time value, false if it is greater than or equal to the second time value.

    <time> <= <time>

Returns true if the first time value is less than or equal to the second time value, false if it is greater than the second time value.

    <time> as <class>

You can coerce a time value to an Integer or Float number - you get the time in ticks:

EXAMPLE
    sliderTime = 35
    35
    currentTime
    35f
    currentTime as integer
    5600
    currentTime as float
    5600.0
    (currentTime as integer)/TicksPerFrame
    35
    (currentTime as float)/TicksPerFrame
    35.0

Note

To coerce a Time Value to Frames integer, you can use the .frame property documented above:

    currentTime
    35f
    currentTime as integer
    5600
    currentTime.frame
    35

Methods

    random <time> <time>

Generates a random time value in the range defined by the two time values.

FOR EXAMPLE
    random 10f 100f
POSSIBLE OUTPUT VALUES:
    70.9813f
    78.175f
    59.225f
    ...

Note

To generate full frame random values, use Integers instead of Time Values instead. Integers are always assumed to represent full frames when used in place of Time Values.

    random 10 100

    abs <time>

Returns the absolute value of the time value.

FOR EXAMPLE
    theTime = -100f
    -100f
    abs theTime
    100f

Some of the examples above refer to system global variables. See 3ds Max System Globals for more details.