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 bc1 = c4d.BaseTime(5, 10) # reduced to 1/2 bc2 = c4d.BaseTime(5) # 5/1 bc3 = bc1 / bc2 doc.SetTime(bc3)
c4d.
BaseTime
¶
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 |
---|---|
Parameters: |
|
Return type: | |
Returns: |
A new basetime. |
BaseTime.
__cmp__
(
self
,
other
)
¶
Compare two times with each other.
Parameters: | other ( c4d.BaseTime ) – The time value to compare with. |
---|
BaseTime.
__add__
(
self
,
other
)
¶
Add two times and return the result.
Parameters: | other ( c4d.BaseTime ) – The other value. |
---|---|
Return type: | c4d.BaseTime |
Returns: | The result. |
BaseTime.
__sub__
(
self
,
other
)
¶
Subtract two times and return the result.
Parameters: | other ( c4d.BaseTime ) – The other value. |
---|---|
Return type: | c4d.BaseTime |
Returns: | The result. |
BaseTime.
__mul__
(
self
,
other
)
¶
Multiply two times and return the result.
Parameters: | other ( c4d.BaseTime ) – The other value. |
---|---|
Return type: | c4d.BaseTime |
Returns: | The result. |
BaseTime.
__div__
(
self
,
other
)
¶
Divide two times and return the result.
Parameters: | other ( c4d.BaseTime ) – The other value. |
---|---|
Return type: | c4d.BaseTime |
Returns: | The result. |
BaseTime.
GetFrame
(
fps
)
¶
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. |
---|---|
Return type: | int |
Returns: | 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 numerator. |
---|
BaseTime.
GetNumerator
(
)
¶
Get the numerator part of the internally stored time.
Return type: | float |
---|---|
Returns: | The numerator. |
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 |
---|---|
Returns: | The denominator |
BaseTime.
Get
(
)
¶
Return the time in seconds.
Return type: | float |
---|---|
Returns: | Time in seconds. |
BaseTime.
TimeDif
(
)
¶