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

From Reallusion Wiki!
Jump to: navigation, search
m
m
(One intermediate revision by the same user not shown)
Line 91: Line 91:
 
End frame time - RLPy.RTime
 
End frame time - RLPy.RTime
 
</div>
 
</div>
 +
<syntaxhighlight lang="Python">
 +
import RLPy
 +
 +
time = RLPy.RGlobal.GetEndTime() # Grab the end time in milliseconds.
 +
 +
# Get seconds from milliseconds.
 +
mark_out_secs = round(time.GetValue() * 0.001)
 +
print("Timeline mark-out located at {0} seconds.".format(mark_out_secs))
 +
 +
# Timeline mark-out located at 30 seconds.
 +
 +
mark_out_frame = RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps())
 +
print("Timeline mark-out on frame {0}.".format(mark_out_frame))
 +
 +
# Timeline mark-out on frame 1799.
 +
</syntaxhighlight>
 
-----
 
-----
 
=== GetFps ===
 
=== GetFps ===
Line 102: Line 118:
 
</div>
 
</div>
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
 +
import RLPy
 +
 
# Get the project frames per second.
 
# Get the project frames per second.
  
import RLPy
+
print(RLPy.RGlobal.GetFps()) # Get frames per second
# Get frames per second
+
print(RLPy.RGlobal.GetFps())
+
  
#60
+
# 60
 
</syntaxhighlight>
 
</syntaxhighlight>
 
-----
 
-----
Line 155: Line 171:
 
</div>
 
</div>
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
# Print out a few path locations (Individual path locations may vary).
 
 
 
import RLPy
 
import RLPy
 +
 +
# Print out a few path locations (Individual path locations may vary).
  
 
temp = ""
 
temp = ""
Line 192: Line 208:
 
</div>
 
</div>
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
# Retrieve the length of the project in ms.
 
 
 
import RLPy
 
import RLPy
  
# Fetch the current frame time in milliseconds.
+
# Grab the project duration in milliseconds
time = RLPy.RGlobal.GetTime()
+
time = RLPy.RGlobal.GetProjectLength()
 +
 
 +
project_secs = round(time.GetValue() * 0.001)
 +
print("This project length is {0} seconds.".format(project_secs))
 +
 
 +
# This project length is 30 seconds.
 +
 
 +
project_frames = RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps())
 +
print("This project has {0} frames.".format(project_frames))
  
# Return the current frame time in milliseconds.
+
# This project has 1800 frames.
print(time.GetValue())
+
 
</syntaxhighlight>
 
</syntaxhighlight>
 
-----
 
-----
Line 212: Line 233:
 
Start frame time - RLPy.RTime
 
Start frame time - RLPy.RTime
 
</div>
 
</div>
 +
<syntaxhighlight lang="Python">
 +
import RLPy
 +
 +
time = RLPy.RGlobal.GetStartTime() # Grab the start time in milliseconds.
 +
print("Timeline starts at {0} milliseconds.".format(time.GetValue()))
 +
 +
# Timeline starts at 0.0 milliseconds.
 +
</syntaxhighlight>
 
-----
 
-----
 
=== GetTime ===
 
=== GetTime ===
Line 222: Line 251:
 
Current time - RLPy.RTime
 
Current time - RLPy.RTime
 
</div>
 
</div>
 +
<syntaxhighlight lang="Python">
 +
import RLPy
 +
 +
time = RLPy.RGlobal.GetTime() # Get the current frame time.
 +
print(time.GetValue()) # Return the current frame time in milliseconds.
 +
</syntaxhighlight>
 
-----
 
-----
 
=== IsPlaying ===
 
=== IsPlaying ===
Line 233: Line 268:
 
</div>
 
</div>
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
# Check if the timeline playback is active.
 
 
 
import RLPy
 
import RLPy
 +
 +
# Check if the timeline playback is active.
  
 
print(RLPy.RGlobal.IsPlaying())
 
print(RLPy.RGlobal.IsPlaying())
Line 259: Line 294:
 
'''kEnd''' [IN] end time - RLPy.RTime
 
'''kEnd''' [IN] end time - RLPy.RTime
 
</div>
 
</div>
 +
<syntaxhighlight lang="Python">
 +
import RLPy
 +
 +
RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000)) # play from 0 to 1 second
 +
</syntaxhighlight>
 
-----
 
-----
 
=== RemoveAllAnimations ===
 
=== RemoveAllAnimations ===
Line 305: Line 345:
 
'''RLPy.RStatus.Failure''' Fail
 
'''RLPy.RStatus.Failure''' Fail
 
</div>
 
</div>
 +
<syntaxhighlight lang="Python">
 +
import RLPy
 +
 +
frame = 50
 +
# convert frame number to RTime.
 +
time = RLPy.RTime.IndexedFrameTime(frame, RLPy.RGlobal.GetFps())
 +
RLPy.RGlobal.SetTime(time) # Move the playhead to the indexed frame time.
 +
</syntaxhighlight>
 
-----
 
-----
 
=== Stop ===
 
=== Stop ===

Revision as of 19:27, 25 April 2019

Main article: Modules.

Detailed Description

This class providing common API global functions.

# Get Secen info
print(RLPy.RGlobal.GetProjectLength()) # print project length of the current scene
print(RLPy.RGlobal.GetFps()) # print 60 FPS

# Time info
RLPy.RGlobal.SetTime(RLPy.RTime(30000)) # set time to 30s
print(RLPy.RGlobal.GetTime().GetValue()) # print 30000
print(RLPy.RGlobal.GetStartTime().GetValue()) # print start time
print(RLPy.RGlobal.GetEndTime().GetValue()) # print end time

# play control
RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000)) # play form 0 to 1s
RLPy.RGlobal.Stop() # stop
RLPy.RGlobal.Pause() # pause

# Get Environment info
temp = ""
ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_Temp, temp) # print path,like: Temp,TemplateContent,CustomContent......
print(ret_list[1])

# undo / redo
RLPy.RGlobal.BeginAction("Motion")
# do something
RLPy.RGlobal.EndAction()

Member Functions

BeginAction

RLPy.RGlobal.BeginAction ( strAction )

Begin action.

Parameters

strAction [IN] action name - string


DoPluginTrialFollowUp

RLPy.RGlobal.DoPluginTrialFollowUp ( strProductNamePath )

Trial Follow up (Internal use)

Parameters

strProductNamePath [IN] Product name path - string


DoSNVerification

RLPy.RGlobal.DoSNVerification ( nProductID, strRegistry, strProductName, strSNFailTitle, strSNFailMsg, strSNExceedTitle, strSNExceedMsg )

Verify serial number.

Parameters

nProductID [IN] product ID - int

strRegistry [IN] registry - string

strProductName [IN] product name - string

strSNFailTitle [IN] fail title - string

strSNFailMsg [IN] fail message - string

strSNExceedTitle [IN] exceed title - string

strSNExceedMsg [IN] exceed message - string

Returns

Remain days of trial version - bool


EndAction

RLPy.RGlobal.EndAction ( )

End action.


GetEndTime

RLPy.RGlobal.GetEndTime ( )

Get end frame time.

Returns

End frame time - RLPy.RTime

import RLPy

time = RLPy.RGlobal.GetEndTime() # Grab the end time in milliseconds.

# Get seconds from milliseconds.
mark_out_secs = round(time.GetValue() * 0.001)
print("Timeline mark-out located at {0} seconds.".format(mark_out_secs))

# Timeline mark-out located at 30 seconds.

mark_out_frame = RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps())
print("Timeline mark-out on frame {0}.".format(mark_out_frame))

# Timeline mark-out on frame 1799.

GetFps

RLPy.RGlobal.GetFps ( )

Get frame per second.

Returns

Frame rate - int

import RLPy

# Get the project frames per second.

print(RLPy.RGlobal.GetFps()) # Get frames per second

# 60

GetMocapManager

RLPy.RGlobal.GetMocapManager ( )

Get mocap manager.

Returns

Pointer to mocap manager - RLPy.RIMocapManager


GetPath

RLPy.RGlobal.GetPath ( ePath, strPath )

Get path.

Parameters

ePath [IN] path type - RLPy.EPathType

  • RLPy.EPathType_Temp Temporary folder.
  • RLPy.EPathType_TemplateContent Template content folder.
  • RLPy.EPathType_CustomContent Custom content folder.
  • RLPy.EPathType_ProgramDefault Program default folder.
  • RLPy.EPathType_Morph Morph data folder.
  • RLPy.EPathType_CreateFace CreateFace data folder.
  • RLPy.EPathType_Puppet Puppet data folder.
  • RLPy.EPathType_FacialLayer Facial layer data folder.
  • RLPy.EPathType_ShareTemplateContent Shared template content folder.
  • RLPy.EPathType_Thumb Thumbnail folder.
  • RLPy.EPathType_Image Image folder.
  • RLPy.EPathType_CreatorAssets Creator assets folder.
  • RLPy.EPathType_Resource Resource folder.
  • RLPy.EPathType_FacialSystem Facial system folder.
  • RLPy.EPathType_CustomWidget Custom widget folder.
  • RLPy.EPathType_iCloneAssets iClone assets folder

strPath [OUT] path name - string

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail

import RLPy

# Print out a few path locations (Individual path locations may vary).

temp = ""
ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_Temp, temp)
print("Temp folder: "+ret_list[1])

# Temp folder: C:\Users\User_Name\AppData\Local\Temp\iClone7Temp\iClone7Temp\

ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_TemplateContent, temp)
print("Template content folder: "+ret_list[1])

# Template content folder: C:\Users\Public\Documents\Reallusion\Template\iClone 7 Template

ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_CustomContent, temp)
print("Custom content folder: "+ret_list[1])

# Custom content folder: C:\Users\Public\Documents\Reallusion\Custom\iClone 7 Custom

ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_ProgramDefault, temp)
print("Program default folder: "+ret_list[1])

# Program default folder: C:\Program Files\Reallusion\iClone 7\Program\Default\

GetProjectLength

RLPy.RGlobal.GetProjectLength ( )

Get project length.

Returns

Project length - RLPy.RTime

import RLPy

# Grab the project duration in milliseconds
time = RLPy.RGlobal.GetProjectLength()

project_secs = round(time.GetValue() * 0.001)
print("This project length is {0} seconds.".format(project_secs))

# This project length is 30 seconds.

project_frames = RLPy.RTime.GetFrameIndex(time, RLPy.RGlobal.GetFps())
print("This project has {0} frames.".format(project_frames))

# This project has 1800 frames.

GetStartTime

RLPy.RGlobal.GetStartTime ( )

Get start frame time.

Returns

Start frame time - RLPy.RTime

import RLPy

time = RLPy.RGlobal.GetStartTime() # Grab the start time in milliseconds.
print("Timeline starts at {0} milliseconds.".format(time.GetValue()))

# Timeline starts at 0.0 milliseconds.

GetTime

RLPy.RGlobal.GetTime ( )

Get current frame time.

Returns

Current time - RLPy.RTime

import RLPy

time = RLPy.RGlobal.GetTime() # Get the current frame time.
print(time.GetValue()) # Return the current frame time in milliseconds.

IsPlaying

RLPy.RGlobal.IsPlaying ( )

Is application playing?

Returns

True when application playing - bool

import RLPy

# Check if the timeline playback is active.

print(RLPy.RGlobal.IsPlaying())

# True / False

Pause

RLPy.RGlobal.Pause ( )

Pause the project.


Play

RLPy.RGlobal.Play ( kStart, kEnd )

Play the project.

Parameters

kStart [IN] start time - RLPy.RTime

kEnd [IN] end time - RLPy.RTime

import RLPy

RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000)) # play from 0 to 1 second

RemoveAllAnimations

RLPy.RGlobal.RemoveAllAnimations ( spObject )

Remove all animations of object. ( Experimental API )

Parameters

spObject [IN] The object to remove animations - RLPy.RIObject

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Remove failed


RenderVideo

RLPy.RGlobal.RenderVideo ( )

Export project into video file. ( Experimental API )

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Remove failed


SetTime

RLPy.RGlobal.SetTime ( kTime )

Set current frame time.

Parameters

kTime [IN] Specifies the time to set - RLPy.RTime

Return Values

RLPy.RStatus.Success Success

RLPy.RStatus.Failure Fail

import RLPy

frame = 50
# convert frame number to RTime.
time = RLPy.RTime.IndexedFrameTime(frame, RLPy.RGlobal.GetFps())
RLPy.RGlobal.SetTime(time) # Move the playhead to the indexed frame time.

Stop

RLPy.RGlobal.Stop ( )

Stop playing.


TrialVersionRemainingDays

RLPy.RGlobal.TrialVersionRemainingDays ( strBinPath, uProductID, strProductFold, strRegRoot )

Get remain days of trial version.

Parameters

strBinPath [IN] bin file path - string

kProductID [IN] product ID

kProductFold [IN] product Folder

kRegRoot [IN] registry root

Returns

Remain days of trial version - int