# c4d.BaseTime¶

CINEMA 4D uses a very sophisticated system for specifying time values. If only frame numbers were used, changing the frame rate would cause keys either to overlap or disappear. If only float values (seconds) were used instead, there would be problems because of the limited data precision. For example when using 30 fps the frame 29 = 29/30 could easily be misinterpreted as frame 28.

CINEMA 4D has a time class that internally stores the time values as exact fractions independent of the frame rate. For example frame 29 is stored as fraction with nominator 29 and denominator 30. The class always tries to keep the nominator and denominator as small as possible. Hence 15/30 is stored as 1/2. Now when using 30 fps BaseTime.GetFrame() will return 15, but when using 24 fps it will return frame 12:

```The fraction:          1/2
Frames per second:     30
Frame in document:     **15**```

Otherwise take a look at this example:

```The fraction:          8/1
Frames per second:     25
Frame in document:     **200**```

Class to manage BaseTime. Here is an example how to use a BaseTime object:

```import c4d
from c4d import documents

bc1 = c4d.BaseTime(5, 10) # reduced to 1/2
bc2 = c4d.BaseTime(5)     # 5/1
bc3 = bc1 / bc2
doc = documents.GetActiveDocument()
doc.SetTime(bc3)
```

## Definition¶

class c4d.BaseTime

## Members¶

static BaseTime.__init__([z[, n]])

Initializes the internal time value from a real value in seconds. This will multiply the seconds by 1000.0 and store it as a fraction with the denominator at 1000.0.

Name z: int z – Optional time in seconds. n (bool or int) – If n is False, disable the automatic fraction-reduction and if int, set the denominator. BaseTime A new basetime.
BaseTime.__cmp__(self, other)

Compare two times with each other.

Parameters: other (BaseTime) – The value to compare with.

Add two times and return the result.

Parameters: other (BaseTime) – The other value. BaseTime The result
BaseTime.__sub__(self, other)

Subtract two times and return the result.

Parameters: other (BaseTime) – The other value. BaseTime The result
BaseTime.__mul__(self, other)

Multiply two times and return the result.

Parameters: other (BaseTime) – The other value. BaseTime The result
BaseTime.__div__(self, other)

Divide two times and return the result.

Parameters: other (BaseTime) – The other value. BaseTime The result
BaseTime.GetFrame(fps)

Sets the ID of the container.

Get the number of frames equivalent to this time for the given number of frames per second.

Parameters: fps (int) – The number of frames for this time. int The frames per second to use to calculate the frame number for this time.
BaseTime.Quantize(fps)

Quantizes the internal value so that it is a multiple of the specified framerate.

Parameters: fps (number) – The number of frames per second to make this time a multiple of.
BaseTime.SetNumerator(r)

Set the numerator part of the internally stored time.

Parameters: r (number) – The nominator.
BaseTime.GetNumerator()

Get the numerator part of the internally stored time.

Return type: float the nominator
BaseTime.SetDenominator(r)

Get the denominator part of the internally stored time.

Parameters: r (number) – The denominator.
BaseTime.GetDenominator()

Get the denominator part of the internally stored time.

Return type: float the denominator
BaseTime.Get()

Return the time in seconds.

Return type: float Time in seconds.
BaseTime.TimeDif()

Return the time in seconds.

Return type: float Time in seconds.