This documentation is for the free plugin Py4D in CINEMA 4D R11.5 and not for the C4DSDK of Python in CINEMA 4D R12. For R12, please visit PluginCafe.com

c4d.BaseTime – a time class

The internal time class of CINEMA 4D.

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 BaseTimes. 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
documents.GetActiveDocument.SetTime(bc3)
class c4d.BaseTime

Methods

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

Parameters:
  • z – Optional time in seconds.
  • n (bool or int) – If n is False, disable the automatic fraction-reduction and if int, set the denominator.
Return type:

BaseTime or None

Returns:

A new basetime.

BaseTime.__cmp__(self, other)

Compare two times with each other.

Parameter:other (BaseTime) – The value to compare with.
BaseTime.__add__(self, other)

Add two times and return the result.

Parameter:other (BaseTime) – The other value.
Return type:BaseTime
Returns:The result
BaseTime.__sub__(self, other)

Subtract two times and return the result.

Parameter:other (BaseTime) – The other value.
Return type:BaseTime
Returns:The result
BaseTime.__mul__(self, other)

Multiply two times and return the result.

Parameter:other (BaseTime) – The other value.
Return type:BaseTime
Returns:The result
BaseTime.__div__(self, other)

Divide two times and return the result.

Parameter:other (BaseTime) – The other value.
Return type:BaseTime
Returns: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.

Parameter: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.

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

Get the nominator part of the internally stored time.

Parameter:r (number) – The nominator.
BaseTime.GetNominator()

Get the nominator part of the internally stored time.

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

Get the denominator part of the internally stored time.

Parameter: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.TimeDiff()

Return the time in seconds.

Return type:float
Returns:Time in seconds.

Table Of Contents

This Page