IC Python API:RLPy RTime

From Reallusion Wiki!
Jump to: navigation, search
Main article: Modules.

Detailed Description

This class is used to hold and manipulate timing information. Time is stored internally in system as milliseconds. Most API methods that require or return timing information do so through variables of

this type. This class also provide methods to convert between Frame and RTime, such as GetFrameIndex() and IndexedFrameTime(). Use GetFrameTime() can ensure that RTime is on the correct frame.
time = RLPy.RGlobal.GetTime()

# compare time
if time == RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
 print("equal")
else if time > RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
 print("greater")
else if time < RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
 print("less")

# operator
time += RLPy.RTime(1000)
time -= RLPy.RTime(1000)
time *= 2
time /= 2

# convert between Frame
time = RLPy.RTime(3000)
print(RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps())) # 180

time = RLPy.RTime.IndexedFrameTime(180, RLPy.RGlobal.GetFps())
print(time.GetValue()) # 3000

time = RLPy.RTime(3005)
frame_time = RLPy.RTime.GetFrameTime(time, RLPy.RGlobal.GetFps())
print(frame_time.GetValue()) # 3000

Constructor & Destructors

__init__

RLPy.RTime.__init__ ( self, args )

Constructor, Initialize a new RTime object with a float value and an unit.

Parameters

fValue [IN] a float value representing a time - float

eUnit [IN] a time unit - RLPy.Unit

  • RLPy.kInvalid
  • RLPy.kHours not support
  • RLPy.kMinutes not support
  • RLPy.kSeconds not support
  • RLPy.kMilliseconds 1/1000 of a second
  • RLPy.k30FPS not support
  • RLPy.k60FPS 60 frames per second
  • RLPy.kUserDef not support

Operators

This class supports the following operators:

Member Operation Syntax Description Example
__add__ Addition a + b Adds values on either side of the operator. a + b = 30
__sub__ Subtraction a - b Subtracts right hand operand from left hand operand. a – b = -10
__mul__ Multiplication a * b Multiplies values on either side of the operator. a * b = 200
__truediv__ Division a / b Divides left hand operand by right hand operand. b / a = 2
__eq__ Equality a == b If the values of two operands are equal, then the condition becomes true. (a == b) is not true.
__ne__ Difference a != b If values of two operands are not equal, then condition becomes true. (a != b) is true.
__gt__ Greater Than a > b If the value of left operand is greater than the value of right operand, then condition becomes true. (a > b) is not true.
__lt__ Less Than a < b If the value of left operand is less than the value of right operand, then condition becomes true. (a < b) is true.
__ge__ Greater Than or Equal a >= b If the value of left operand is greater than or equal to the value of right operand, then condition becomes true. (a >= b) is not true.
__le__ Less or Equal a <= b If the value of left operand is less than or equal to the value of right operand, then condition becomes true. (a <= b) is true.
__iadd__ Addition (Inplace) a += b It adds right operand to the left operand and assign the result to left operand. c += a is equivalent to c = c + a
__isub__ Subtraction (Inplace) a -= b It subtracts right operand from the left operand and assign the result to left operand. c -= a is equivalent to c = c - a
__imul__ Multiply (Inplace) a *= b It multiplies right operand with the left operand and assign the result to left operand. c *= a is equivalent to c = c * a
__itruediv__ Divide (Inplace) a /= b It divides left operand with the right operand and assign the result to left operand. c /= a is equivalent to c = c / ac /= a is equivalent to c = c / a

Member Functions

AsUnits

RLPy.RTime.AsUnits ( self, eUnit )

Returns the current time value in the given units. This does not affect the current units for the instance.

Parameters

eUnit [IN] a time unit - RLPy.Unit

  • RLPy.kInvalid
  • RLPy.kHours not support
  • RLPy.kMinutes not support
  • RLPy.kSeconds not support
  • RLPy.kMilliseconds 1/1000 of a second
  • RLPy.k30FPS not support
  • RLPy.k60FPS 60 frames per second
  • RLPy.kUserDef not support

Returns

The current time value in the given units - float

GetFrameIndex

RLPy.RTime.GetFrameIndex ( kTime, nFps )

Get frame index from frame time.

Parameters

kTime [IN] the time for this frame - RLPy.RTime

nFps [IN] frames per second - int

Returns

The frame index - int

GetFrameTime

RLPy.RTime.GetFrameTime ( kTime, nFps )

Get frame time from a time. The time of a RTime object may not located exactly on a frame. Call this function to get the closest frame time for this RTime object.

Parameters

kTime [IN] the time in an animation - RLPy.RTime

nFps [IN] frames per second - int

Returns

The frame time - RLPy.RTime

GetUnit

RLPy.RTime.GetUnit ( self )

Get the unit of this RTime object.

Returns

The unit of this RTime object - RLPy.Unit
  • RLPy.kInvalid
  • RLPy.kHours not support
  • RLPy.kMinutes not support
  • RLPy.kSeconds not support
  • RLPy.kMilliseconds 1/1000 of a second
  • RLPy.k30FPS not support
  • RLPy.k60FPS 60 frames per second
  • RLPy.kUserDef not support

GetValue

RLPy.RTime.GetValue ( self )

Get the float value of this RTime object.

Returns

The float value of this RTime object - float

IndexedFrameTime

RLPy.RTime.IndexedFrameTime ( nFrameIndex, nFps )

Get frame time from frame index.

Parameters

nFrameIndex [IN] the frame index for this frame time - int

nFps [IN] frames per second - int

Returns

The frame time - RLPy.RTime

SetUnit

RLPy.RTime.SetUnit ( self, eUnit )

Set time unit.

Parameters

eUnit [IN] a time unit - RLPy.Unit

  • RLPy.kInvalid
  • RLPy.kHours not support
  • RLPy.kMinutes not support
  • RLPy.kSeconds not support
  • RLPy.kMilliseconds 1/1000 of a second
  • RLPy.k30FPS not support
  • RLPy.k60FPS 60 frames per second
  • RLPy.kUserDef not support

SetValue

RLPy.RTime.SetValue ( self, fValue )

Set the float value of a time.

Parameters

fValue [IN] a float value of a time - float