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

From Reallusion Wiki!
Jump to: navigation, search
m
m
Line 65: Line 65:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
print(RLPy.RGlobal.GetProjectLength()) # print project duration for the current scene
 
print(RLPy.RGlobal.GetProjectLength()) # print project duration for the current scene
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 77: Line 76:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
print(RLPy.RGlobal.GetFps())
 
print(RLPy.RGlobal.GetFps())
 
</syntaxhighlight>
 
</syntaxhighlight>
Line 161: Line 159:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
temp = ""
 
temp = ""
 
ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_Temp, temp)
 
ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_Temp, temp)
Line 176: Line 173:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
RLPy.RGlobal.BeginAction('ActionName')
 
RLPy.RGlobal.BeginAction('ActionName')
 
RLPy.RGlobal.EndAction()
 
RLPy.RGlobal.EndAction()
Line 197: Line 193:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
start_time = RLPy.RTime(0)
 
start_time = RLPy.RTime(0)
 
end_time = RLPy.RTime(1000.0)
 
end_time = RLPy.RTime(1000.0)
Line 208: Line 203:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
 
RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
 
RLPy.RGlobal.Pause()
 
RLPy.RGlobal.Pause()
Line 218: Line 212:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
 
RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
 
RLPy.RGlobal.Stop()
 
RLPy.RGlobal.Stop()
Line 231: Line 224:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
if(not RLPy.RGlobal.IsPlaying()):
 
if(not RLPy.RGlobal.IsPlaying()):
 
         RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
 
         RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
Line 246: Line 238:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
time = RLPy.RGlobal.GetTime()
 
time = RLPy.RGlobal.GetTime()
 
print(time)
 
print(time)
Line 265: Line 256:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
result = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
 
result = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
 
print(result) # Success or fail
 
print(result) # Success or fail
Line 281: Line 271:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
time = RLPy.RGlobal.GetStartTime()
 
time = RLPy.RGlobal.GetStartTime()
 
print(time)
 
print(time)
Line 294: Line 283:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
time = RLPy.RGlobal.GetEndTime()
 
time = RLPy.RGlobal.GetEndTime()
 
print(time)
 
print(time)
Line 309: Line 297:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
mocap_manager = RLPy.RGlobal.GetMocapManager()
 
mocap_manager = RLPy.RGlobal.GetMocapManager()
 
print(mocap_manager.IsRunning())
 
print(mocap_manager.IsRunning())
Line 326: Line 313:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
avatar_list = RLPy.RScene.GetAvatars()
 
avatar_list = RLPy.RScene.GetAvatars()
 
result = RLPy.RGlobal.RemoveAllAnimations( avatar_list[0] )
 
result = RLPy.RGlobal.RemoveAllAnimations( avatar_list[0] )
Line 341: Line 327:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
result = RLPy.RGlobal.RenderVideo()
 
result = RLPy.RGlobal.RenderVideo()
 
print(result)
 
print(result)
Line 362: Line 347:
  
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
import RLPy
 
 
width = 0
 
width = 0
 
height = 0
 
height = 0

Revision as of 02:27, 26 March 2020

Main article: Modules.
Last modified: 03/26/2020

Description

This class provides global settings and information for the application, like querying project related settings like GetFps, GetTime, GetScreenSize, etc., and operations such as SetTime, RenderVideo, etc.

# 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()

# Get Mocap Manager
mocap_manager = RLPy.RGlobal.GetMocapManager()
print(mocap_manager.IsRunning()) #true or false

# Remove All Animation
avatar_list = RLPy.RScene.GetAvatars()
result = RLPy.RGlobal.RemoveAllAnimations(avatar_list[0])
print(result)#RLPy.RStatus.Success or RLPy.RStatus.Failure

# Render Video
print(RLPy.RGlobal.RenderVideo())
#RLPy.RStatus.Success or RLPy.RStatus.Failure

# Get Screen Size
width = 0
height = 0
result = RLPy.RGlobal.GetScreenSize(width, height)
print(result[0]) #RLPy.RStatus.Success or RLPy.RStatus.Failure 
print(result[1]) #screen width
print(result[2]) #screen height

Member Functions

GetProjectLength ( )

Get the current project duration.

Returns

Project duration - RLPy.RTime
print(RLPy.RGlobal.GetProjectLength()) # print project duration for the current scene

GetFps ( )

Get the frames-per-second for the current project. Currently fixed at 60 fps.

Returns

Frame rate - int
print(RLPy.RGlobal.GetFps())

GetPath ( )

This function can return the absolute paths for the following directories:

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

Parameters

ePath [IN] path type - RLPy.EPathType
  • RLPy.EPathType_Temp
  • RLPy.EPathType_TemplateContent
  • RLPy.EPathType_CustomContent
  • RLPy.EPathType_ProgramDefault
  • RLPy.EPathType_Morph
  • RLPy.EPathType_CreateFace
  • RLPy.EPathType_Puppet
  • RLPy.EPathType_FacialLayer
  • RLPy.EPathType_ShareTemplateContent
  • RLPy.EPathType_Thumb
  • RLPy.EPathType_Image
  • RLPy.EPathType_CreatorAssets
  • RLPy.EPathType_Resource
  • RLPy.EPathType_FacialSystem
  • RLPy.EPathType_CustomWidget
  • RLPy.EPathType_iCloneAssets
strPath [OUT] path name - string

Returns

Success - RLPy.RStatus.Success
Fail - RLPy.RStatus.Failure
temp = ""
ret_list = RLPy.RGlobal.GetPath(RLPy.EPathType_Temp, temp)
print(ret_list[0]) # success or faild
print(ret_list[1]) # path

BeginAction ( )

Perform undo and redo actions. This function is currently incomplete.

Parameters

strAction [IN] action name - string
RLPy.RGlobal.BeginAction('ActionName')
RLPy.RGlobal.EndAction()

EndAction ( )

Perform undo and redo actions. This function is currently incomplete

Play ( )

Controls the timeline playback.

Parameters

kStart [IN] start time - RLPy.RTime
kEnd [IN] end time - RLPy.RTime
start_time = RLPy.RTime(0)
end_time = RLPy.RTime(1000.0)
RLPy.RGlobal.Play(start_time,end_time)

Pause ( )

Pause the timeline playback and keep the playhead in place.

RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
RLPy.RGlobal.Pause()

Stop ( )

Stop the timeline playback and return the playhead to the start marker.

RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
RLPy.RGlobal.Stop()

IsPlaying ( )

Check if timeline playback is in progress.

Returns

Returns true when application playing - bool
if(not RLPy.RGlobal.IsPlaying()):
        RLPy.RGlobal.Play(RLPy.RTime(0), RLPy.RTime(1000))
if(RLPy.RGlobal.IsPlaying()):
        RLPy.RGlobal.Stop()

GetTime ( )

Get the current time for the scene according to the location of the playhead.

Returns

current time - RLPy.RTime
time = RLPy.RGlobal.GetTime()
print(time)

SetTime ( )

Change the current time for the scene and update the playhead.

See Also: GetTime

Parameters

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

Returns

Success - RLPy.RStatus.Success
Fail - RLPy.RStatus.Failure
result = RLPy.RGlobal.SetTime(RLPy.RTime(1000))
print(result) # Success or fail

time = RLPy.RGlobal.GetTime()
print(time)

GetStartTime ( )

Get the start time for the current project.

Returns

Start frame time - RLPy.RTime
time = RLPy.RGlobal.GetStartTime()
print(time)

GetEndTime ( )

Get the end time for the current project.

Returns

End frame time - RLPy.RTime
time = RLPy.RGlobal.GetEndTime()
print(time)

GetMocapManager ()

Access the Mocap Manager and member functions for RLPy.RIMocapManager.

See Also: RIMocapManager

Returns

Pointer to mocap manager - RLPy.RIMocapManager
mocap_manager = RLPy.RGlobal.GetMocapManager()
print(mocap_manager.IsRunning())

RemoveAllAnimations ( spObject )

Remove all animations on a given object and return RLPy.RStatus.Success if successful, else RLPy.RStatus.Failure. Currently supports characters, props, accessories, particles, PopcornFX, lights, motion paths, cameras, wind, images, and global illumination. The timeline needs to update after execution in order to show the changes.

Parameters

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

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
avatar_list = RLPy.RScene.GetAvatars()
result = RLPy.RGlobal.RemoveAllAnimations( avatar_list[0] )
print(result)

RenderVideo ()

Use the current iClone render settings to output a video. Returns RLPy.RStatus.Success when successful, else RLPy.RStatus.Failure.

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
result = RLPy.RGlobal.RenderVideo()
print(result)

GetScreenSize ( self, nWidth, nHeight )

Get the render output size for the current scene.

Parameters

nWidth [IN] screen width in pixels - int
nHeight [IN] screen height in pixels - int

Returns

[Success/Fail, Width, Height] - list
Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
Width - int
Height - int
width = 0
height = 0
result = RLPy.RGlobal.GetScreenSize(width, height)
print(result[0]) # successful or failed
print(result[1]) # width
print(result[2]) # height