Difference between revisions of "IC Python API:RLPy RTime"

From Reallusion Wiki!
Jump to: navigation, search
m
m
Line 5: Line 5:
 
== Description ==
 
== Description ==
  
This class represents the midst unit (a.k.a unit of time) in animation.  Currently, it provides two states: milliseconds and 60FPS (frames per second).  When you create an animation key, you'll need to set the value according to the incoming time.  This class also provides different unit conversions such as '''GetFrameIndex()''', '''IndexedFrameTime()''', and '''GetFrameTime()''' to ensure that the time retrieved is alined with animation frames.
+
This class represents the midst unit (a.k.a unit of time) in animation.  Currently, it provides two states: milliseconds and 60FPS (frames per second).  When you create an animation key, you'll need to set the value according to the incoming time.  This class also provides different unit conversions such as [[#GetFrameIndex ( self, kTime, nFps )|GetFrameIndex]], [[#IndexedFrameTime ( self, nFrameIndex, nFps )|IndexedFrameTime]], and [[#GetFrameTime ( self, kTime, nFps )|GetFrameTime]] to ensure that the time retrieved is alined with animation frames.
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Get current time
 
# Get current time
 
time = RLPy.RGlobal.GetTime()
 
time = RLPy.RGlobal.GetTime()
Line 38: Line 38:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
== Member Functions ==
+
== Operators ==
  
=== __init__ ( self, args ) ===
+
=== == ===
  
This operation creates an instance of an RTime object.
+
The "equal to" operator. Check if two time objects are equal.
 
+
Currently provided units of time (RLPy.Unit):
+
 
+
{| class="wikitable"
+
!Unit
+
!Description
+
|-
+
|RLPy.kInvalid
+
|Invalid value
+
|-
+
|RLPy.kHours
+
|Not supported
+
|-
+
|RLPy.kMinutes
+
|Not supported
+
|-
+
|RLPy.kSeconds
+
|Not supported
+
|-
+
|RLPy.kMilliseconds
+
|1000 units per second
+
|-
+
|RLPy.k30FPS
+
|Not supported
+
|-
+
|RLPy.k60FPS
+
|1 second equals 60 frames
+
|-
+
|RLPy.kUserDef
+
|Not supported
+
|}
+
 
+
<syntaxhighlight lang="Python">
+
# Constructor RTime object
+
time1 = RLPy.RTime()
+
 
+
# Constructor RTime object with RTime object
+
time2 = RLPy.RTime(time1)
+
 
+
# Constructor RTime object with float value and unit
+
time3 = RLPy.RTime(0, RLPy.kMilliseconds)
+
</syntaxhighlight>
+
 
+
=== GetUnit ( self ) ===
+
 
+
Get the midst unit for the RTime object.
+
 
+
See Also: [[#SetUnit( self, eUnit )|SetUnit( self, eUnit )]]
+
  
 
==== Returns ====
 
==== Returns ====
:Midst unit of a given RTime object - RLPy.Unit
+
:'''True''' if the values of the two time objects are equal, else '''False'''.
  
<syntaxhighlight lang="Python">
+
See Also: [[#!=|!=]]
# Get time unit
+
time = RLPy.RTime(0, RLPy.kMilliseconds)
+
time_unit = time.GetUnit()
+
print(time_unit)
+
</syntaxhighlight>
+
 
+
=== GetValue ( self ) ===
+
 
+
Get the time value of the RTime object.
+
 
+
See Also: [[#SetValue( self, fValue )|SetValue( self, fValue )]]
+
 
+
==== Returns ====
+
:Time value of the RTime object - float
+
 
+
<syntaxhighlight lang="Python">
+
# Get time value
+
time = RLPy.RTime(3000)
+
time_value = time.GetValue()
+
print(time_value)
+
</syntaxhighlight>
+
 
+
=== SetUnit ( self, eUnit ) ===
+
 
+
Set the midst unit for the RTime object.
+
 
+
See Also: [[#RTime.GetUnit( self )|GetUnit( self )]]
+
 
+
==== Parameters ====
+
:eUnit [IN] Midst unit - RLPy.Unit
+
 
+
<syntaxhighlight lang="Python">
+
# Set time unit
+
time = RLPy.RTime(0)
+
time.SetUnit(RLPy.k60FPS)
+
</syntaxhighlight>
+
 
+
=== SetValue ( self, fValue ) ===
+
 
+
Set the time value for the RTime object.
+
 
+
See Also: [[#RTime.GetValue( self )|GetValue( self )]]
+
 
+
==== Parameters ====
+
:fValue [IN] Time value - float
+
 
+
<syntaxhighlight lang="Python">
+
# Set time value
+
time = RLPy.RTime(0)
+
time.SetValue(3000)
+
</syntaxhighlight>
+
 
+
=== AsUnits ( self, eUnit ) ===
+
 
+
Convert the time value to a specified midst unit without changing it for the RTime object.
+
 
+
==== Returns ====
+
:The converted time value of the RTime object in the specified midst unit - float
+
 
+
<syntaxhighlight lang="Python">
+
# As units milliseconds
+
time = RLPy.RTime(2000)
+
time_value = time.AsUnits(RLPy.kMilliseconds)
+
</syntaxhighlight>
+
 
+
=== __eq__ ( self, rhs ) ===
+
 
+
RTime quivalence operator.
+
 
+
==== Parameters ====
+
:rhs [IN] a reference to the RTime object for comparison.
+
 
+
==== Returns ====
+
:If the values of the two RTime objects are equal return '''true''', otherwise return '''false'''.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Equivalence operator
 
# Equivalence operator
 
time1 = RLPy.RTime(3000)
 
time1 = RLPy.RTime(3000)
Line 178: Line 56:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __ne__ ( self, rhs ) ===
+
=== != ===
  
RTime not equal operator.
+
The "not equal to" operator.  Check if two time object are not equal.
  
==== Parameters ====
+
==== Returns ====
:rhs [IN] a reference to the RTime object for comparison.
+
:'''True''' if the values of the two time objects are not equal, otherwise return '''False'''.
  
==== Returns ====
+
See Also: [[#==|==]]
:If the values of the two RTime objects are not equal return '''true''', otherwise return '''false'''.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Not equal operator
 
# Not equal operator
 
time1 = RLPy.RTime(3000)
 
time1 = RLPy.RTime(3000)
Line 195: Line 72:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __le__ ( self, rhs ) ===
+
=== < ===
  
RTime less than operator.
+
The "less than" operator.  Check if a time object is less than another.
  
==== Parameters ====
+
==== Returns ====
:rhs [IN] a reference to the RTime object for comparison.
+
:'''True''' if this value is less than or equal to another [[IC_Python_API:RLPy_RTime|RTime]]value, else '''False'''.
  
==== Returns ====
+
See Also: [[#<=|<=]]
:If the value is less than or equal to the target RTime object (rhs) return '''true''', otherwise return '''false'''.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Less equal operator
 
# Less equal operator
 
time1 = RLPy.RTime(1000)
 
time1 = RLPy.RTime(1000)
Line 212: Line 88:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __ge__ ( self, rhs ) ===
+
=== >= ===
  
RTime greater or equal to operator.
+
The "greater than or equal" operator.  Check if a time object is greater than or equal to another.
  
==== Parameters ====
+
==== Returns ====
:rhs [IN] a reference to the RTime object for comparison.
+
:'''True''' if this [[IC_Python_API:RLPy_RTime|RTime]]value is greater than or equal to another [[IC_Python_API:RLPy_RTime|RTime]]value, else '''False'''.
  
==== Returns ====
+
See Also: [[#>|>]]
:If the value is greater than or equal to the target RTime object (rhs) return '''true''', otherwise return '''false'''.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Less equal operator
 
# Less equal operator
 
time1 = RLPy.RTime(2000)
 
time1 = RLPy.RTime(2000)
Line 229: Line 104:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __lt__ ( self, rhs ) ===
+
=== < ===
  
RTime less than operator.
+
The "less than" operator. Check if a time object is less than another.
 
+
==== Parameters ====
+
:rhs [IN] a reference to the RTime object for comparison.
+
  
 
==== Returns ====
 
==== Returns ====
:If the value is less than the target RTime object (rhs) return '''true''', otherwise return '''false'''.
+
:'''True''' if this [[IC_Python_API:RLPy_RTime|RTime]]value is less than another [[IC_Python_API:RLPy_RTime|RTime]]value, else '''False'''.
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Less than operator
 
# Less than operator
 
time1 = RLPy.RTime(1000)
 
time1 = RLPy.RTime(1000)
Line 246: Line 118:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __gt__ ( self, rhs ) ===
+
=== > ===
  
RTime greater than operator.
+
The "greater than" operator.  Check if a time object is greater than another.
  
==== Parameters ====
+
==== Returns ====
:rhs [IN] a reference to the RTime object for comparison.
+
:'''True''' if this [[IC_Python_API:RLPy_RTime|RTime]]value is greater than another [[IC_Python_API:RLPy_RTime|RTime]]value, else '''False'''.
  
==== Returns ====
+
See Also: [[#>=|>=]]
:The value is greater than the target RTime object (rhs) return '''true''', otherwise return '''false'''.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Greater than operator
 
# Greater than operator
 
time1 = RLPy.RTime(3000)
 
time1 = RLPy.RTime(3000)
Line 263: Line 134:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __add__ ( self, args ) ===
+
=== + ===
  
RTime addition operator.
+
The addition operator.  Add 2 time objects together.
  
==== Parameters ====
+
==== Returns ====
:args [IN] a reference to the added RTime object.
+
:Sum of the two time objects - [[IC_Python_API:RLPy_RTime|RTime]]
  
==== Returns ====
+
See Also: [[#+=|+=]]
:Sum of the two RTime objects.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Addition operator
 
# Addition operator
 
time1 = RLPy.RTime(1000)
 
time1 = RLPy.RTime(1000)
Line 281: Line 151:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __iadd__ ( self, args ) ===
+
=== += ===
  
RTime addition assignment operator.
+
The "addition assignment" operator. Add a time object to this time object.
 
+
==== Parameters ====
+
:args [IN] a reference to the addend RTime object.
+
  
 
==== Returns ====
 
==== Returns ====
:Sum of the two RTime objects.
+
:Sum of the two time objects.
  
<syntaxhighlight lang="Python">
+
See Also: [[#+|+]]
 +
 
 +
<syntaxhighlight lang="python">
 
# Addition assignment operator
 
# Addition assignment operator
 
time1 = RLPy.RTime(1000)
 
time1 = RLPy.RTime(1000)
Line 299: Line 168:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __sub__ ( self, args ) ===
+
=== - ===
  
RTime subtraction operator.
+
The 'subtraction' operator.  Minus a time object from another.
  
==== Parameters ====
+
==== Returns ====
:args [IN] a reference to the minuend RTime object.
+
:Difference of the two time objects - [[IC_Python_API:RLPy_RTime|RTime]]
  
==== Returns ====
+
See Also: [[#-=|-=]]
:Difference of the two RTime objects.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Subtraction operator
 
# Subtraction operator
 
time1 = RLPy.RTime(1000)
 
time1 = RLPy.RTime(1000)
Line 317: Line 185:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __isub__ ( self, args ) ===
+
=== -= ===
  
RTime subtraction assignment operator.
+
The "subtraction assignment" operator.  Subtract a time object from this time object.
  
==== Parameters ====
+
==== Returns ====
:args [IN] a reference to the minuend RTime object.
+
:Difference of the two time objects - [[IC_Python_API:RLPy_RTime|RTime]]
  
==== Returns ====
+
See Also: [[#-|-]]
:Difference of the two RTime objects.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Subtraction assignment operator
 
# Subtraction assignment operator
 
time1 = RLPy.RTime(1000)
 
time1 = RLPy.RTime(1000)
Line 335: Line 202:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __mul__ ( self, args ) ===
+
=== * ===
  
RTime multiplication operator.
+
The "multiplication" operator. Multiply two time objects.
 
+
==== Parameters ====
+
:args [IN] a float value of multiplier.
+
  
 
==== Returns ====
 
==== Returns ====
:RTime object with the multiplied value.
+
:Time object with the multiplied value - [[IC_Python_API:RLPy_RTime|RTime]]
  
<syntaxhighlight lang="Python">
+
See Also: [[#*=|*=]]
 +
 
 +
<syntaxhighlight lang="python">
 
# Multiplication operator
 
# Multiplication operator
 
time1 = RLPy.RTime(100.0)
 
time1 = RLPy.RTime(100.0)
Line 352: Line 218:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __imul__ ( self, args ) ===
+
=== *= ===
  
RTime multiplication assignment operator.
+
The "multiplication assignment" operator.  Mutliply a time object to this time object.
  
==== Parameters ====
+
==== Returns ====
:args [IN] a float value as the multiplier.
+
:Time object with the product value - [[IC_Python_API:RLPy_RTime|RTime]]
  
==== Returns ====
+
See Also: [[#*|*]]
:RTime object with the product value.
+
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Multiplication assignment operator
 
# Multiplication assignment operator
 
time1 = RLPy.RTime(200.0)
 
time1 = RLPy.RTime(200.0)
Line 369: Line 234:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __truediv__ ( self, args ) ===
+
=== / ===
  
RTime division operator.
+
The "division" operator. Divide two time objects.
 
+
==== Parameters ====
+
:args [IN] a float value as the divisor.
+
  
 
==== Returns ====
 
==== Returns ====
:RTime object with the quotient value.
+
:Time object with the quotient value - [[IC_Python_API:RLPy_RTime|RTime]]
  
<syntaxhighlight lang="Python">
+
See Also: [[#/=|/=]]
 +
 
 +
<syntaxhighlight lang="python">
 
# Division operator
 
# Division operator
 
time1 = RLPy.RTime(3000)
 
time1 = RLPy.RTime(3000)
Line 386: Line 250:
 
</syntaxhighlight>
 
</syntaxhighlight>
  
=== __itruediv__ ( self, args ) ===
+
=== /= ===
  
RTime division assignment operator.
+
The "division assignment" operator. Divide a time object from this time object.
 
+
==== Parameters ====
+
:args [IN] a float value as the divisor.
+
  
 
==== Returns ====
 
==== Returns ====
:RTime object with the quotient value.
+
:Time object with the quotient value - [[IC_Python_API:RLPy_RTime|RTime]]
  
<syntaxhighlight lang="Python">
+
See Also: [[#/|/]]
 +
 
 +
<syntaxhighlight lang="python">
 
# Division assignment operator
 
# Division assignment operator
 
time1 = RLPy.RTime(3000.0)
 
time1 = RLPy.RTime(3000.0)
 
time1 /= 15
 
time1 /= 15
 
print(time1)
 
print(time1)
 +
</syntaxhighlight>
 +
 +
== Member Functions ==
 +
 +
=== __init__ ( self, args ) ===
 +
 +
This operation creates a time object instance.
 +
 +
Currently provided units of time (RLPy.Unit):
 +
 +
{| class="wikitable"
 +
!Unit
 +
!Description
 +
|-
 +
|RLPy.kInvalid
 +
|Invalid value
 +
|-
 +
|RLPy.kHours
 +
|Not supported
 +
|-
 +
|RLPy.kMinutes
 +
|Not supported
 +
|-
 +
|RLPy.kSeconds
 +
|Not supported
 +
|-
 +
|RLPy.kMilliseconds
 +
|1000 units per second
 +
|-
 +
|RLPy.k30FPS
 +
|Not supported
 +
|-
 +
|RLPy.k60FPS
 +
|1 second equals 60 frames
 +
|-
 +
|RLPy.kUserDef
 +
|Not supported
 +
|}
 +
 +
<syntaxhighlight lang="python">
 +
# Constructor RTime object
 +
time1 = RLPy.RTime()
 +
 +
# Constructor RTime object with RTime object
 +
time2 = RLPy.RTime(time1)
 +
 +
# Constructor RTime object with float value and unit
 +
time3 = RLPy.RTime(0, RLPy.kMilliseconds)
 +
</syntaxhighlight>
 +
 +
=== GetUnit ( self ) ===
 +
 +
Get the midst unit for the time object.
 +
 +
See Also: [[#SetUnit( self, eUnit )|SetUnit( self, eUnit )]]
 +
 +
==== Returns ====
 +
:Midst unit of a given time object - RLPy.Unit
 +
 +
<syntaxhighlight lang="python">
 +
# Get time unit
 +
time = RLPy.RTime(0, RLPy.kMilliseconds)
 +
time_unit = time.GetUnit()
 +
print(time_unit)
 +
</syntaxhighlight>
 +
 +
=== GetValue ( self ) ===
 +
 +
Get the time value of the time object.
 +
 +
See Also: [[#SetValue( self, fValue )|SetValue( self, fValue )]]
 +
 +
==== Returns ====
 +
:Time value of the time object - float
 +
 +
<syntaxhighlight lang="python">
 +
# Get time value
 +
time = RLPy.RTime(3000)
 +
time_value = time.GetValue()
 +
print(time_value)
 +
</syntaxhighlight>
 +
 +
=== SetUnit ( self, eUnit ) ===
 +
 +
Set the midst unit for the time object.
 +
 +
See Also: [[#RTime.GetUnit( self )|GetUnit( self )]]
 +
 +
==== Parameters ====
 +
:'''eUnit''' [IN] Midst unit - RLPy.Unit
 +
 +
<syntaxhighlight lang="python">
 +
# Set time unit
 +
time = RLPy.RTime(0)
 +
time.SetUnit(RLPy.k60FPS)
 +
</syntaxhighlight>
 +
 +
=== SetValue ( self, fValue ) ===
 +
 +
Set the time value for the time object.
 +
 +
See Also: [[#RTime.GetValue( self )|GetValue( self )]]
 +
 +
==== Parameters ====
 +
:'''fValue''' [IN] Time value - float
 +
 +
<syntaxhighlight lang="python">
 +
# Set time value
 +
time = RLPy.RTime(0)
 +
time.SetValue(3000)
 +
</syntaxhighlight>
 +
 +
=== AsUnits ( self, eUnit ) ===
 +
 +
Convert the time value to a specified midst unit without changing it for the time object.
 +
 +
==== Returns ====
 +
:The converted time value of the time object in the specified midst unit - float
 +
 +
<syntaxhighlight lang="python">
 +
# As units milliseconds
 +
time = RLPy.RTime(2000)
 +
time_value = time.AsUnits(RLPy.kMilliseconds)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Line 408: Line 394:
  
 
==== Parameters ====
 
==== Parameters ====
:nFps [IN] frames per second - int
+
:'''nFps''' [IN] frames per second - int
  
 
==== Returns ====
 
==== Returns ====
 
:The corresponding frame index - int
 
:The corresponding frame index - int
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Get frame index
 
# Get frame index
 
frame_index = RLPy.RTime.GetFrameIndex(RLPy.RTime(3000.0), 60)
 
frame_index = RLPy.RTime.GetFrameIndex(RLPy.RTime(3000.0), 60)
Line 421: Line 407:
 
=== IndexedFrameTime ( self, nFrameIndex, nFps ) ===
 
=== IndexedFrameTime ( self, nFrameIndex, nFps ) ===
  
Get the RTime of a given frame index based on a specified FPS.
+
Get the time of a given frame index based on a specified FPS.
  
 
==== Parameters ====
 
==== Parameters ====
:nFrameIndex [IN] input frame index - int
+
:'''nFrameIndex''' [IN] input frame index - int
:nFps [IN] frames per second - int
+
:'''nFps''' [IN] frames per second - int
  
 
==== Returns ====
 
==== Returns ====
:The corresponding RTime - RLPy.RTime
+
:The corresponding time - [[IC_Python_API:RLPy_RTime|RTime]]
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Get indexed frame time
 
# Get indexed frame time
 
frame_time = RLPy.RTime.IndexedFrameTime(180, 60)
 
frame_time = RLPy.RTime.IndexedFrameTime(180, 60)
Line 441: Line 427:
  
 
==== Parameters ====
 
==== Parameters ====
:kTime [IN] animation time - RLPy.RTime
+
:'''kTime''' [IN] animation time - [[IC_Python_API:RLPy_RTime|RTime]]
:nFps [IN] frames per second - int
+
:'''nFps''' [IN] frames per second - int
  
 
==== Returns ====
 
==== Returns ====
:The corresponding RTime - RLPy.RTime
+
:The corresponding time - [[IC_Python_API:RLPy_RTime|RTime]]
  
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python">
 
# Get frame time
 
# Get frame time
 
frame_time = RLPy.RTime.GetFrameTime(RLPy.RTime(3002), 60)
 
frame_time = RLPy.RTime.GetFrameTime(RLPy.RTime(3002), 60)
 
print(time2)
 
print(time2)
 
</syntaxhighlight>
 
</syntaxhighlight>

Revision as of 23:07, 8 April 2020

Main article: Modules.
Last modified: 04/8/2020

Description

This class represents the midst unit (a.k.a unit of time) in animation. Currently, it provides two states: milliseconds and 60FPS (frames per second). When you create an animation key, you'll need to set the value according to the incoming time. This class also provides different unit conversions such as GetFrameIndex, IndexedFrameTime, and GetFrameTime to ensure that the time retrieved is alined with animation frames.

# Get current time
time = RLPy.RGlobal.GetTime()
 
# Compare time
if time == RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
   print("equal")
elif time > RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
   print("greater")
elif 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)
frame_index = RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps())
print(frame_index)            # 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

Operators

==

The "equal to" operator. Check if two time objects are equal.

Returns

True if the values of the two time objects are equal, else False.

See Also: !=

# Equivalence operator
time1 = RLPy.RTime(3000)
time2 = RLPy.RTime(3000)
print(time1 == time2)

!=

The "not equal to" operator. Check if two time object are not equal.

Returns

True if the values of the two time objects are not equal, otherwise return False.

See Also: ==

# Not equal operator
time1 = RLPy.RTime(3000)
time2 = RLPy.RTime(3000, RLPy.k60FPS)
print(time1 != time2)

<

The "less than" operator. Check if a time object is less than another.

Returns

True if this value is less than or equal to another RTimevalue, else False.

See Also: <=

# Less equal operator
time1 = RLPy.RTime(1000)
time2 = RLPy.RTime(2000)
print(time1 <= time2)

>=

The "greater than or equal" operator. Check if a time object is greater than or equal to another.

Returns

True if this RTimevalue is greater than or equal to another RTimevalue, else False.

See Also: >

# Less equal operator
time1 = RLPy.RTime(2000)
time2 = RLPy.RTime(1000)
print(time1 >= time2)

<

The "less than" operator. Check if a time object is less than another.

Returns

True if this RTimevalue is less than another RTimevalue, else False.
# Less than operator
time1 = RLPy.RTime(1000)
time2 = RLPy.RTime(3000)
print(time1 < time2)

>

The "greater than" operator. Check if a time object is greater than another.

Returns

True if this RTimevalue is greater than another RTimevalue, else False.

See Also: >=

# Greater than operator
time1 = RLPy.RTime(3000)
time2 = RLPy.RTime(1000)
print(time1 > time2)

+

The addition operator. Add 2 time objects together.

Returns

Sum of the two time objects - RTime

See Also: +=

# Addition operator
time1 = RLPy.RTime(1000)
time2 = RLPy.RTime(2000)
time3 = time1 + time2
print(time3)

+=

The "addition assignment" operator. Add a time object to this time object.

Returns

Sum of the two time objects.

See Also: +

# Addition assignment operator
time1 = RLPy.RTime(1000)
time2 = RLPy.RTime(3000)
time1 += time2
print(time1)

-

The 'subtraction' operator. Minus a time object from another.

Returns

Difference of the two time objects - RTime

See Also: -=

# Subtraction operator
time1 = RLPy.RTime(1000)
time2 = RLPy.RTime(2000)
time3 = time2 - time1
print(time3)

-=

The "subtraction assignment" operator. Subtract a time object from this time object.

Returns

Difference of the two time objects - RTime

See Also: -

# Subtraction assignment operator
time1 = RLPy.RTime(1000)
time2 = RLPy.RTime(3000)
time2 -= time1
print(time2)

*

The "multiplication" operator. Multiply two time objects.

Returns

Time object with the multiplied value - RTime

See Also: *=

# Multiplication operator
time1 = RLPy.RTime(100.0)
time2 = time1 * 0.5
print(time2)

*=

The "multiplication assignment" operator. Mutliply a time object to this time object.

Returns

Time object with the product value - RTime

See Also: *

# Multiplication assignment operator
time1 = RLPy.RTime(200.0)
time1 *= 1.5
print(time1)

/

The "division" operator. Divide two time objects.

Returns

Time object with the quotient value - RTime

See Also: /=

# Division operator
time1 = RLPy.RTime(3000)
time2 = time1 / 150
print(time2)

/=

The "division assignment" operator. Divide a time object from this time object.

Returns

Time object with the quotient value - RTime

See Also: /

# Division assignment operator
time1 = RLPy.RTime(3000.0)
time1 /= 15
print(time1)

Member Functions

__init__ ( self, args )

This operation creates a time object instance.

Currently provided units of time (RLPy.Unit):

Unit Description
RLPy.kInvalid Invalid value
RLPy.kHours Not supported
RLPy.kMinutes Not supported
RLPy.kSeconds Not supported
RLPy.kMilliseconds 1000 units per second
RLPy.k30FPS Not supported
RLPy.k60FPS 1 second equals 60 frames
RLPy.kUserDef Not supported
# Constructor RTime object
time1 = RLPy.RTime()

# Constructor RTime object with RTime object
time2 = RLPy.RTime(time1)

# Constructor RTime object with float value and unit
time3 = RLPy.RTime(0, RLPy.kMilliseconds)

GetUnit ( self )

Get the midst unit for the time object.

See Also: SetUnit( self, eUnit )

Returns

Midst unit of a given time object - RLPy.Unit
# Get time unit
time = RLPy.RTime(0, RLPy.kMilliseconds)
time_unit = time.GetUnit()
print(time_unit)

GetValue ( self )

Get the time value of the time object.

See Also: SetValue( self, fValue )

Returns

Time value of the time object - float
# Get time value
time = RLPy.RTime(3000)
time_value = time.GetValue()
print(time_value)

SetUnit ( self, eUnit )

Set the midst unit for the time object.

See Also: GetUnit( self )

Parameters

eUnit [IN] Midst unit - RLPy.Unit
# Set time unit
time = RLPy.RTime(0)
time.SetUnit(RLPy.k60FPS)

SetValue ( self, fValue )

Set the time value for the time object.

See Also: GetValue( self )

Parameters

fValue [IN] Time value - float
# Set time value
time = RLPy.RTime(0)
time.SetValue(3000)

AsUnits ( self, eUnit )

Convert the time value to a specified midst unit without changing it for the time object.

Returns

The converted time value of the time object in the specified midst unit - float
# As units milliseconds
time = RLPy.RTime(2000)
time_value = time.AsUnits(RLPy.kMilliseconds)

GetFrameIndex ( self, kTime, nFps )

Get the frame index of a given time based on a specified FPS.

Parameters

nFps [IN] frames per second - int

Returns

The corresponding frame index - int
# Get frame index
frame_index = RLPy.RTime.GetFrameIndex(RLPy.RTime(3000.0), 60)
print(frame_index)

IndexedFrameTime ( self, nFrameIndex, nFps )

Get the time of a given frame index based on a specified FPS.

Parameters

nFrameIndex [IN] input frame index - int
nFps [IN] frames per second - int

Returns

The corresponding time - RTime
# Get indexed frame time
frame_time = RLPy.RTime.IndexedFrameTime(180, 60)
print(frame_time)

GetFrameTime ( self, kTime, nFps )

Checks if the input time falls on a specific frame based on the input FPS. If the time does not match up correctly with any frame, then return the time of the nearest frame. This ensures that the return value will always align to a specific animation frame.

Parameters

kTime [IN] animation time - RTime
nFps [IN] frames per second - int

Returns

The corresponding time - RTime
# Get frame time
frame_time = RLPy.RTime.GetFrameTime(RLPy.RTime(3002), 60)
print(time2)