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

From Reallusion Wiki!
Jump to: navigation, search
m (IndexedFrameTime)
m
 
(21 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
{{Parent|IC_Python_API:RL_Python_Modules#System|System Module}}
+
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
+
{{last_modified}}
Class in RLPy / Inherits from: _object
+
  
 
== Description ==
 
== Description ==
  
This class is used to hold and manipulate timing information.
+
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 aligned with animation frames.
 
+
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 of GetFrameTime() can ensure that RTime is on the correct frame.
+
  
 
== Operators ==
 
== Operators ==
  
This class supports the mathematical operators.
+
=== == ===
  
<div class="toccolours mw-collapsible mw-collapsed">
+
The "equal to" operator.  Check if two time objects are equal.
Addition and Subtraction
+
<div class="mw-collapsible-content">
+
<syntaxhighlight lang="Python">
+
import RLPy
+
  
time = RLPy.RTime(3000)
+
==== Returns ====
time += RLPy.RTime(1000)
+
:'''True''' if the values of the two time objects are equal, else '''False'''.
time -= RLPy.RTime(1000)
+
  
# Functionally the same as:
+
See Also: [[#!=|!=]]
time += 1000
+
time -= 1000
+
  
print(time.GetValue())
+
<syntaxhighlight lang="python" line='line'>
 +
# Equivalence operator
 +
time1 = RLPy.RTime(3000)
 +
time2 = RLPy.RTime(3000)
 +
print(time1 == time2)
  
# 3000.0
+
# Compare current time
 +
time = RLPy.RGlobal.GetTime()
 +
 
 +
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")
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
</div>
 
  
<div class="toccolours mw-collapsible mw-collapsed">
+
=== != ===
Multiplication and Division
+
<div class="mw-collapsible-content">
+
<syntaxhighlight lang="Python">
+
import RLPy
+
  
time = RLPy.RTime(3000)
+
The "not equal to" operator.  Check if two time object are not equal.
time *= 2
+
time /= 2
+
  
# Functionaly the same as:
+
==== Returns ====
time = time * 2
+
:'''True''' if the values of the two time objects are not equal, otherwise return '''False'''.
time = time / 2
+
  
print(time.GetValue())
+
See Also: [[#==|==]]
  
#3000.0
+
<syntaxhighlight lang="python" line='line'>
 +
# Not equal operator
 +
time1 = RLPy.RTime(3000)
 +
time2 = RLPy.RTime(3000, RLPy.k60FPS)
 +
print(time1 != time2)
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
</div>
 
  
<div class="toccolours mw-collapsible mw-collapsed">
+
=== < ===
Order of operation
+
<div class="mw-collapsible-content">
+
  
<syntaxhighlight lang="Python">
+
The "less than" operator.  Check if a time object is less than another.
import RLPy
+
  
time = RLPy.RTime(1)
+
==== Returns ====
time = time + 3 * 2
+
:'''True''' if this value is less than or equal to another [[IC_Python_API:RLPy_RTime|RTime]]value, else '''False'''.
print(time.GetValue())
+
  
time = RLPy.RTime(1)
+
See Also: [[#<=|<=]]
time = time * 2 + 3
+
print(time.GetValue())
+
  
# 7.0
+
<syntaxhighlight lang="python" line='line'>
# 5.0
+
# Less equal operator
 +
time1 = RLPy.RTime(1000)
 +
time2 = RLPy.RTime(2000)
 +
print(time1 <= time2)
 +
</syntaxhighlight>
 +
 
 +
=== >= ===
 +
 
 +
The "greater than or equal" operator.  Check if a time object is greater than or equal to another.
 +
 
 +
==== Returns ====
 +
:'''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'''.
 +
 
 +
See Also: [[#>|>]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Less equal operator
 +
time1 = RLPy.RTime(2000)
 +
time2 = RLPy.RTime(1000)
 +
print(time1 >= time2)
 +
</syntaxhighlight>
 +
 
 +
=== < ===
 +
 
 +
The "less than" operator.  Check if a time object is less than another.
 +
 
 +
==== Returns ====
 +
:'''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" line='line'>
 +
# Less than operator
 +
time1 = RLPy.RTime(1000)
 +
time2 = RLPy.RTime(3000)
 +
print(time1 < time2)
 +
</syntaxhighlight>
 +
 
 +
=== > ===
 +
 
 +
The "greater than" operator.  Check if a time object is greater than another.
 +
 
 +
==== Returns ====
 +
:'''True''' if this [[IC_Python_API:RLPy_RTime|RTime]]value is greater than another [[IC_Python_API:RLPy_RTime|RTime]]value, else '''False'''.
 +
 
 +
See Also: [[#>=|>=]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Greater than operator
 +
time1 = RLPy.RTime(3000)
 +
time2 = RLPy.RTime(1000)
 +
print(time1 > time2)
 +
</syntaxhighlight>
 +
 
 +
=== + ===
 +
 
 +
The addition operator.  Add two time objects together.
 +
 
 +
==== Returns ====
 +
:Sum of the two time objects - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#+=|+=]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Addition operator
 +
time1 = RLPy.RTime(1000)
 +
time2 = RLPy.RTime(2000)
 +
time3 = time1 + time2
 +
print(time3)
 +
</syntaxhighlight>
 +
 
 +
=== += ===
 +
 
 +
The "addition assignment" operator. Add a time object to this time object.
 +
 
 +
==== Returns ====
 +
:Sum of the two time objects.
 +
 
 +
See Also: [[#+|+]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Addition assignment operator
 +
time1 = RLPy.RTime(1000)
 +
time2 = RLPy.RTime(3000)
 +
time1 += time2
 +
print(time1)
 +
</syntaxhighlight>
 +
 
 +
=== - ===
 +
 
 +
The 'subtraction' operator.  Minus a time object from another.
 +
 
 +
==== Returns ====
 +
:Difference of the two time objects - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#-=|-=]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Subtraction operator
 +
time1 = RLPy.RTime(1000)
 +
time2 = RLPy.RTime(2000)
 +
time3 = time2 - time1
 +
print(time3)
 +
</syntaxhighlight>
 +
 
 +
=== -= ===
 +
 
 +
The "subtraction assignment" operator.  Subtract a time object from this time object.
 +
 
 +
==== Returns ====
 +
:Difference of the two time objects - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#-|-]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Subtraction assignment operator
 +
time1 = RLPy.RTime(1000)
 +
time2 = RLPy.RTime(3000)
 +
time2 -= time1
 +
print(time2)
 +
</syntaxhighlight>
 +
 
 +
=== * ===
 +
 
 +
The "multiplication" operator.  Multiply two time objects.
 +
 
 +
==== Returns ====
 +
:Time object with the multiplied value - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#*=|*=]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Multiplication operator
 +
time1 = RLPy.RTime(100.0)
 +
time2 = time1 * 0.5
 +
print(time2)
 +
</syntaxhighlight>
 +
 
 +
=== *= ===
 +
 
 +
The "multiplication assignment" operator.  Mutliply a time object to this time object.
 +
 
 +
==== Returns ====
 +
:Time object with the product value - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#*|*]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Multiplication assignment operator
 +
time1 = RLPy.RTime(200.0)
 +
time1 *= 1.5
 +
print(time1)
 +
</syntaxhighlight>
 +
 
 +
=== / ===
 +
 
 +
The "division" operator.  Divide two time objects.
 +
 
 +
==== Returns ====
 +
:Time object with the quotient value - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#/=|/=]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Division operator
 +
time1 = RLPy.RTime(3000)
 +
time2 = time1 / 150
 +
print(time2)
 +
</syntaxhighlight>
 +
 
 +
=== /= ===
 +
 
 +
The "division assignment" operator.  Divide a time object from this time object.
 +
 
 +
==== Returns ====
 +
:Time object with the quotient value - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
See Also: [[#/|/]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Division assignment operator
 +
time1 = RLPy.RTime(3000.0)
 +
time1 /= 15
 +
print(time1)
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
</div>
 
  
 
== Member Functions ==
 
== Member Functions ==
  
=== GetFrameIndex ===
+
=== __init__ ( self, args ) ===
 +
 
 +
This operation creates a time object instance.
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Constructor RTime object
 +
time1 = RLPy.RTime()
 +
 
 +
# Constructor RTime object with RTime object
 +
time2 = RLPy.RTime(time1)
  
<syntaxhighlight lang="Python">
+
# Constructor RTime object with float value and unit
def RLPy.RTime.GetFrameIndex(kTime, nFps)
+
time3 = RLPy.RTime(0, RLPy.kMilliseconds)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Convert the current time to frame index.  Since iClone is 60 frames per second, the return value is usually the time in seconds times 60.
+
=== GetUnit ( self ) ===
  
<div class="toccolours mw-collapsible mw-collapsed">
+
Get the midst unit for the time object.
The following example gives the frame index at the 3 second mark:
+
<div class="mw-collapsible-content">
+
<syntaxhighlight lang="Python">
+
import RLPy
+
  
# Create a time object of 3 seconds.
+
See Also: [[#SetUnit( self, eUnit )|SetUnit( self, eUnit )]]
time = RLPy.RTime(3000)
+
  
# Print the frame index at the 3 second mark.
+
==== Returns ====
print(RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps()))
+
:Midst unit of a given time object - [[IC_Python_API:Enums#RLPy.Unit|RLPy.Unit]]
  
# 180
+
<syntaxhighlight lang="python" line='line'>
 +
# Get time unit
 +
time = RLPy.RTime(0, RLPy.kMilliseconds)
 +
time_unit = time.GetUnit()
 +
print(time_unit)
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
</div>
 
  
=== GetFrameTime ===
+
=== GetValue ( self ) ===
  
<syntaxhighlight lang="Python">
+
Get the time value of the time object.
def RLPy.RTime.GetFrameTime(kTime,nFps)
+
 
 +
See Also: [[#SetValue( self, fValue )|SetValue( self, fValue )]]
 +
 
 +
==== Returns ====
 +
:Time value of the time object - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get time value
 +
time = RLPy.RTime(3000)
 +
time_value = time.GetValue()
 +
print(time_value)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Deduce the frame time from a time object.
+
=== SetUnit ( self, eUnit ) ===
  
The RTime object may not give a time that perfectly matches a frame.  Call this function to get the closest frame time for a RTime object - not to be confused with frame index.
+
Set the midst unit for the time object.
  
<div class="toccolours mw-collapsible mw-collapsed">
+
See Also: [[#RTime.GetUnit( self )|GetUnit( self )]]
The following code retrieves the frame accurate time from a given time value:
+
<div class="mw-collapsible-content">
+
<syntaxhighlight lang="Python">
+
import RLPy
+
  
# Construct time object that does not align perfectly with a frame.
+
==== Parameters ====
time = RLPy.RTime(3005)
+
:'''eUnit''' [IN] Midst unit - [[IC_Python_API:Enums#RLPy.Unit|RLPy.Unit]]
  
# Derive the nearest frame time from the RTime object.
+
<syntaxhighlight lang="python" line='line'>
frame_time = RLPy.RTime.GetFrameTime(time, RLPy.RGlobal.GetFps())
+
# 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 )]]
  
# Print the frame-aligned time in milliseconds.
+
==== Parameters ====
print(frame_time.GetValue())
+
:'''fValue''' [IN] Time value - float
  
# 3000.0
+
<syntaxhighlight lang="python" line='line'>
 +
# Set time value
 +
time = RLPy.RTime(0)
 +
time.SetValue(3000)
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
</div>
 
  
===IndexedFrameTime===
+
=== AsUnits ( self, eUnit ) ===
  
<syntaxhighlight lang="Python">
+
Convert the time value to a specified midst unit without changing it for the time object.
def RLPy.RTime.IndexedFrameTime(nFrameindex,nFps)
+
 
 +
==== Returns ====
 +
:The converted time value of the time object in the specified midst unit - float
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# As units milliseconds
 +
time = RLPy.RTime(2000)
 +
time_value = time.AsUnits(RLPy.kMilliseconds)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Get the frame time from the frame index.
+
=== GetFrameIndex ( self, kTime, nFps ) ===
  
Since iClone runs 60 frames per second, the resultant time in milliseconds is the usually the frame count divided by 60 times 1000.
+
Get the frame index of a given time based on a specified FPS.
  
<div class="toccolours mw-collapsible mw-collapsed">
+
==== Parameters ====
The following example returns the time in milliseconds to reach the 180th frame.
+
:'''kTime''' [IN] animation time - [[IC_Python_API:RLPy_RTime|RTime]]
<div class="mw-collapsible-content">
+
:'''nFps''' [IN] frames per second - integer
<syntaxhighlight lang="Python">
+
import RLPy
+
  
# Derive the frame time from the frame index
+
==== Returns ====
time = RLPy.RTime.IndexedFrameTime(180, RLPy.RGlobal.GetFps())
+
:The corresponding frame index - integer
  
# 180th frame divided by 60 fps times 1000 ms should return 3000 ms.
+
<syntaxhighlight lang="python" line='line'>
print(time.GetValue())
+
# Get frame index
 +
frame_index = RLPy.RTime.GetFrameIndex(RLPy.RTime(3000.0), 60)
 +
print(frame_index)
 
</syntaxhighlight>
 
</syntaxhighlight>
</div>
 
</div>
 
  
===GetValue===
+
=== IndexedFrameTime ( self, nFrameIndex, nFps ) ===
  
<syntaxhighlight lang="Python">
+
Get the time of a given frame index based on a specified FPS.
def RLPy.RTime.GetValue(self)
+
 
 +
==== Parameters ====
 +
:'''nFrameIndex''' [IN] input frame index - integer
 +
:'''nFps''' [IN] frames per second - integer
 +
 
 +
==== Returns ====
 +
:The corresponding time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
# Get indexed frame time
 +
frame_time = RLPy.RTime.IndexedFrameTime(180, 60)
 +
print(frame_time)
 
</syntaxhighlight>
 
</syntaxhighlight>
  
Get the time in milliseconds for this RTime object.
+
=== GetFrameTime ( self, kTime, nFps ) ===
  
The following example fetches the current frame time in millisecondsThe current frame time is indicated by the position of your play-head in the timeline.
+
Checks if the input time falls on a specific frame based on the input FPSIf 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.
  
<syntaxhighlight lang="Python">
+
==== Parameters ====
import RLPy
+
:'''kTime''' [IN] animation time - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''nFps''' [IN] frames per second - integer
  
# Put the current frame time into a variable.
+
==== Returns ====
time = RLPy.RGlobal.GetTime()
+
:The corresponding time - [[IC_Python_API:RLPy_RTime|RTime]]
  
# Return the current frame time in milliseconds.
+
<syntaxhighlight lang="python" line='line'>
print(time.GetValue())
+
# Get frame time
 +
frame_time = RLPy.RTime.GetFrameTime(RLPy.RTime(3002), 60)
 +
print(time2)
 
</syntaxhighlight>
 
</syntaxhighlight>

Latest revision as of 20:38, 12 May 2020

Main article: Modules.
Last modified: 05/12/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 aligned with animation frames.

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: !=

 1 # Equivalence operator
 2 time1 = RLPy.RTime(3000)
 3 time2 = RLPy.RTime(3000)
 4 print(time1 == time2)
 5 
 6 # Compare current time
 7 time = RLPy.RGlobal.GetTime()
 8 
 9 if time == RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
10    print("equal")
11 elif time > RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
12    print("greater")
13 elif time < RLPy.RGlobal.SetTime(RLPy.RTime(1000)):
14    print("less")

!=

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: ==

1 # Not equal operator
2 time1 = RLPy.RTime(3000)
3 time2 = RLPy.RTime(3000, RLPy.k60FPS)
4 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: <=

1 # Less equal operator
2 time1 = RLPy.RTime(1000)
3 time2 = RLPy.RTime(2000)
4 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: >

1 # Less equal operator
2 time1 = RLPy.RTime(2000)
3 time2 = RLPy.RTime(1000)
4 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.
1 # Less than operator
2 time1 = RLPy.RTime(1000)
3 time2 = RLPy.RTime(3000)
4 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: >=

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

+

The addition operator. Add two time objects together.

Returns

Sum of the two time objects - RTime

See Also: +=

1 # Addition operator
2 time1 = RLPy.RTime(1000)
3 time2 = RLPy.RTime(2000)
4 time3 = time1 + time2
5 print(time3)

+=

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

Returns

Sum of the two time objects.

See Also: +

1 # Addition assignment operator
2 time1 = RLPy.RTime(1000)
3 time2 = RLPy.RTime(3000)
4 time1 += time2
5 print(time1)

-

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

Returns

Difference of the two time objects - RTime

See Also: -=

1 # Subtraction operator
2 time1 = RLPy.RTime(1000)
3 time2 = RLPy.RTime(2000)
4 time3 = time2 - time1
5 print(time3)

-=

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

Returns

Difference of the two time objects - RTime

See Also: -

1 # Subtraction assignment operator
2 time1 = RLPy.RTime(1000)
3 time2 = RLPy.RTime(3000)
4 time2 -= time1
5 print(time2)

*

The "multiplication" operator. Multiply two time objects.

Returns

Time object with the multiplied value - RTime

See Also: *=

1 # Multiplication operator
2 time1 = RLPy.RTime(100.0)
3 time2 = time1 * 0.5
4 print(time2)

*=

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

Returns

Time object with the product value - RTime

See Also: *

1 # Multiplication assignment operator
2 time1 = RLPy.RTime(200.0)
3 time1 *= 1.5
4 print(time1)

/

The "division" operator. Divide two time objects.

Returns

Time object with the quotient value - RTime

See Also: /=

1 # Division operator
2 time1 = RLPy.RTime(3000)
3 time2 = time1 / 150
4 print(time2)

/=

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

Returns

Time object with the quotient value - RTime

See Also: /

1 # Division assignment operator
2 time1 = RLPy.RTime(3000.0)
3 time1 /= 15
4 print(time1)

Member Functions

__init__ ( self, args )

This operation creates a time object instance.

1 # Constructor RTime object
2 time1 = RLPy.RTime()
3 
4 # Constructor RTime object with RTime object
5 time2 = RLPy.RTime(time1)
6 
7 # Constructor RTime object with float value and unit
8 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
1 # Get time unit
2 time = RLPy.RTime(0, RLPy.kMilliseconds)
3 time_unit = time.GetUnit()
4 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
1 # Get time value
2 time = RLPy.RTime(3000)
3 time_value = time.GetValue()
4 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
1 # Set time unit
2 time = RLPy.RTime(0)
3 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
1 # Set time value
2 time = RLPy.RTime(0)
3 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
1 # As units milliseconds
2 time = RLPy.RTime(2000)
3 time_value = time.AsUnits(RLPy.kMilliseconds)

GetFrameIndex ( self, kTime, nFps )

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

Parameters

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

Returns

The corresponding frame index - integer
1 # Get frame index
2 frame_index = RLPy.RTime.GetFrameIndex(RLPy.RTime(3000.0), 60)
3 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 - integer
nFps [IN] frames per second - integer

Returns

The corresponding time - RTime
1 # Get indexed frame time
2 frame_time = RLPy.RTime.IndexedFrameTime(180, 60)
3 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 - integer

Returns

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