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

From Reallusion Wiki!
Jump to: navigation, search
m
m
Line 1: Line 1:
 
{{TOC}}
 
{{TOC}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
 
{{Parent|IC_Python_API:RL_Python_Modules|Modules}}
== Detailed Description ==
+
{{last_modified}}
This class providing methods to access the current scene.
+
 
<span style="background:#ffcccc">( Experimental Class )</span> <syntaxhighlight lang="Python">
+
== Description ==
 +
 
 +
An animation project will usually contain all sorts of objects, such as characters, props, lights, cameras, particle systems, etc. The '''RScene''' class is used to manage these objects in the scene.  It provides many functions for users to find and access these objects.  '''RScene''' is a static class that can be used directly without having to create an instance.  This class provides functions for finding objects by name or type, deleting object, showing / hiding objects, getting and setting selected object, and so on.
 +
 
 +
See Also: [[IC_Python_API:RLPy_RIObject|RIObject]], [[IC_Python_API:RLPy_RIAvatar|RIAvatar]], [[IC_Python_API:RLPy_RIProp|RIProp]]
 +
 
 +
== Member Functions ==
 +
 
 +
=== ClearSelectObjects ( ) ===
 +
 
 +
Deselect everything in the scene.
 +
 
 +
<syntaxhighlight lang="Python">
 +
RLPy.RScene.ClearSelectObjects()
 +
</syntaxhighlight>
 +
 
 +
=== FindObject ( eType, strName ) ===
 +
 
 +
Searches for an object by name and type. Returns the first object that fulfills the search criteria.
 +
 
 +
==== Parameters ====
 +
:'''eType''' [IN] Object type - RLPy.EObjectType
 +
:*RLPy.EObjectType_Object
 +
:*RLPy.EObjectType_Avatar
 +
:*RLPy.EObjectType_Prop
 +
:*RLPy.EObjectType_Camera
 +
:*RLPy.EObjectType_Particle
 +
:*RLPy.EObjectType_Light
 +
:*RLPy.EObjectType_SpotLight
 +
:*RLPy.EObjectType_PointLight
 +
:*RLPy.EObjectType_DirectionalLight
 +
:'''strName''' [IN] Object name - string
 +
 
 +
==== Returns ====
 +
:First object that fulfills the search criteria - [[IC_Python_API:RLPy_RIObject|RIObject]]
 +
 
 +
<syntaxhighlight lang="Python">
 
# find avatar
 
# find avatar
 
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "avatar_name" )
 
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "avatar_name" )
 
print(type(avatar)) #RLPy.RIAvatar
 
print(type(avatar)) #RLPy.RIAvatar
 
 
# find prop
 
# find prop
 
prop = RLPy.RScene.FindObject( RLPy.EObjectType_Prop, "prop_name" )
 
prop = RLPy.RScene.FindObject( RLPy.EObjectType_Prop, "prop_name" )
 
print(type(prop)) #RLPy.RIProp
 
print(type(prop)) #RLPy.RIProp
 
 
# find camera
 
# find camera
camera = RLPy.RScene.FindObject( RLPy.EObjectType_Camera "camera_name" )
+
camera = RLPy.RScene.FindObject( RLPy.EObjectType_Camera, "camera_name" )
 
print(type(camera)) #RLPy.RICamera
 
print(type(camera)) #RLPy.RICamera
 
 
# find particle
 
# find particle
 
particle = RLPy.RScene.FindObject( RLPy.EObjectType_Particle, "particle_name" )
 
particle = RLPy.RScene.FindObject( RLPy.EObjectType_Particle, "particle_name" )
 
print(type(particle)) #RLPy.RIParticle
 
print(type(particle)) #RLPy.RIParticle
 +
</syntaxhighlight>
  
# find avatar and prop
+
=== FindObjects ( args ) ===
result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar RLPy.EObjectType_Prop, "same_name" )
+
 
print(len(result))
+
Searches for all objects that match by name and type.
for i in range(len(result)):
+
 
print(type(result[i])) #RLPy.RIAvatar or RLPy.RIProp
+
See Also: [[#FindObject ( eType, strName )|FindObject()]]
 +
 
 +
==== Parameters ====
 +
:'''eType''' [IN] Object type - RLPy.EObjectType
 +
:*RLPy.EObjectType_Object
 +
:*RLPy.EObjectType_Avatar
 +
:*RLPy.EObjectType_Prop
 +
:*RLPy.EObjectType_Camera
 +
:*RLPy.EObjectType_Particle
 +
:*RLPy.EObjectType_Light
 +
:*RLPy.EObjectType_SpotLight
 +
:*RLPy.EObjectType_PointLight
 +
:*RLPy.EObjectType_DirectionalLight
 +
:'''strName''' [IN] Object name - string
 +
 
 +
==== Returns ====
 +
:All objects that fullfill the search criteria - [[IC_Python_API:RLPy_RIObject|RIObject]] list
  
result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar RLPy.EObjectType_Prop )
 
print(len(result)) # all avatars and props
 
</syntaxhighlight>
 
==Member Functions==
 
===FindObject===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.FindObject ( eType, strName )
+
props = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop, "prop_name" )
 
</syntaxhighlight>
 
</syntaxhighlight>
Returns the first loaded object of EObjectType and matches the specified name.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''eType''' [IN] The type of object to find - RLPy.EObjectType
+
=== GetAvatars ( eAvatarType ) ===
*'''RLPy.EObjectType_Object'''
+
 
*'''RLPy.EObjectType_Avatar'''
+
Get all the characters in the scene. The search results can be filtered by avatar type.
*'''RLPy.EObjectType_Prop'''
+
 
*'''RLPy.EObjectType_Camera'''
+
See Also: [[#FindObject ( eType, strName )|FindObject]], [[#FindObjects ( args )|FindObjects()]]
*'''RLPy.EObjectType_Particle'''
+
 
*'''RLPy.EObjectType_Light'''
+
==== Parameters ====
*'''RLPy.EObjectType_SpotLight'''
+
:'''eAvatarType''' [IN] Character type - RLPy.EAvatarType
*'''RLPy.EObjectType_PointLight'''
+
:*RLPy.EAvatarType_Standard
*'''RLPy.EObjectType_DirectionalLight'''
+
:*RLPy.EAvatarType_NonStandard
 +
:*RLPy.EAvatarType_NonHuman
 +
:*RLPy.EAvatarType_StandardSeries
 +
:*RLPy.EAvatarType_All
 +
 
 +
==== Returns ====
 +
:All avatars that fulfill the search criteria - [[IC_Python_API:RLPy_RIAvatar|RIAvatar]] list
  
'''strName''' [IN] The name of object to find - string
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">It returns null if no Object matches the type and name - RLPy.RIObject
 
</div>
 
-----
 
===FindObjects===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.FindObjects ( args )
+
# Find standard avatars
 +
avatars = RLPy.RScene.GetAvatars( RLPy.EAvatarType_Standard )
 +
 
 +
# Find avatars and props
 +
result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar | RLPy.EObjectType_Prop, "same_name" )
 +
print(len(result))
 +
for i in range(len(result)):
 +
  print(type(result[i]))  #RLPy.RIAvatar or IC_Python_API:RLPy_RIProp|RIProp
 +
 
 +
result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar | RLPy.EObjectType_Prop )
 +
print(len(result)) # All avatars and props
 
</syntaxhighlight>
 
</syntaxhighlight>
Returns a list of all objects of EObjectType type and matches the specified name.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''eType''' [IN] The type of object to find - RLPy.EObjectType
+
=== GetProps () ===
*'''RLPy.EObjectType_Object'''
+
 
*'''RLPy.EObjectType_Avatar'''
+
Get all the props in the scene.
*'''RLPy.EObjectType_Prop'''
+
 
*'''RLPy.EObjectType_Camera'''
+
See Also: [[#FindObject ( eType, strName )|FindObject]], [[#FindObjects ( args )|FindObjects]]
*'''RLPy.EObjectType_Particle'''
+
 
*'''RLPy.EObjectType_Light'''
+
==== Returns ====
*'''RLPy.EObjectType_SpotLight'''
+
:All props - [[IC_Python_API:RLPy_RIObject|RIObject]] list
*'''RLPy.EObjectType_PointLight'''
+
*'''RLPy.EObjectType_DirectionalLight'''
+
  
'''strName''' [IN] The name of object to find - string
 
</div>
 
====Returns====
 
<div style="margin-left: 2em;">The array of objects found matching the type and name specified - list
 
</div>
 
-----
 
===GetAvatars===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.GetAvatars ( args )
+
props = RLPy.RScene.GetProps()
 
</syntaxhighlight>
 
</syntaxhighlight>
Get all avatars in the scene.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''eAvatarType''' [IN] avatar type - RLPy.EAvatarType
+
=== GetSelectedObjects () ===
*'''RLPy.EAvatarType_Standard'''
+
 
*'''RLPy.EAvatarType_NonStandard'''
+
Get all the selected object in the scene. If no objects are selected then return an empty list.
*'''RLPy.EAvatarType_NonHuman'''
+
 
*'''RLPy.EAvatarType_StandardSeries'''
+
See Also: [[#SelectObject ( spObject )|SelectObject]], [[#SelectObjects ( kObjects )|SelectObjects]], [[#ClearSelectObjects ( )|ClearSelectObjects]]
*'''RLPy.EAvatarType_All'''
+
 
</div>
+
==== Returns ====
====Returns====
+
:All selected objects - [[IC_Python_API:RLPy_RIObject|RIObject]] list
<div style="margin-left: 2em;">Avatar list - list
+
 
</div>
+
-----
+
===GetProps===
+
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.GetProps ( )
+
# get selected objects
 +
selection_list = RLPy.RScene.GetSelectedObjects()
 +
print(selection_list) #print selected objects
 
</syntaxhighlight>
 
</syntaxhighlight>
Get all props in the scene.
+
 
<span style="background:#ffcccc">( Experimental API )</span>
+
=== Hide ( spObject ) ===
====Returns====
+
 
<div style="margin-left: 2em;">Prop list - list
+
Hide an object in the scene.
</div>
+
 
-----
+
See Also: [[#Show ( spObject )|Show]]
===GetSelectedObjects===
+
 
 +
==== Parameters ====
 +
:'''spObject''' [IN] Object to be hidden - [[IC_Python_API:RLPy_RIObject|RIObject]]
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.GetSelectedObjects ( )
+
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
 +
RLPy.RScene.Hide(avatar)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get selected objects in the scene.
 
====Returns====
 
<div style="margin-left: 2em;">List of the selected objects - list
 
</div>
 
-----
 
===Hide===
 
<syntaxhighlight lang="Python">
 
RLPy.RScene.Hide ( spObject )
 
</syntaxhighlight>
 
Hide object in the scene.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''spObject''' [IN] Object to be hided - RLPy.RIObject
+
=== RemoveObject ( spObject ) ===
</div>
+
 
-----
+
Remove an object from the scene.
===RemoveObject===
+
 
 +
See Also: [[#Show ( spObject )|Show]]
 +
 
 +
==== Parameters ====
 +
:'''spObject''' [IN] Object for removal - [[IC_Python_API:RLPy_RIObject|RIObject]]
 +
 
 +
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.RemoveObject ( spObject )
+
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
 +
RLPy.RScene.RemoveObject(avatar)
 
</syntaxhighlight>
 
</syntaxhighlight>
Remove object from scene.
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''spObject''' [IN] The object to remove - RLPy.RIObject
+
=== SelectObject ( spObject ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Select an object in the scene.
 +
 
 +
See Also: [[#SelectObjects ( kObjects )|SelectObjects]], [[#ClearSelectObjects ( )|ClearSelectObjects]], [[#GetSelectedObjects ()|GetSelectedObjects]]
 +
 +
==== Parameters ====
 +
:'''spObject''' [IN] Object to be selected - [[IC_Python_API:RLPy_RIObject|RIObject]]
 +
 
 +
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''RLPy.RStatus.Failure''' Remove failed
 
</div>
 
-----
 
===SelectObject===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.SelectObject ( spObject )
+
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
 +
RLPy.RScene.SelectObject(avatar)
 
</syntaxhighlight>
 
</syntaxhighlight>
Select object in the scene.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''spObject''' [IN] specified objects - RLPy.RIObject
+
=== SelectObjects ( kObjects ) ===
</div>
+
 
====Return Values====
+
Select several objects in the scene.
<div style="margin-left: 2em;">
+
 
 +
See Also: [[#SelectObject ( spObject )|SelectObject]], [[#ClearSelectObjects ( )|ClearSelectObjects]], [[#GetSelectedObjects ()|GetSelectedObjects]]
 +
 
 +
==== Parameters ====
 +
:'''kObjects''' [IN] Objects for seletion - [[IC_Python_API:RLPy_RIObject|RIObject]] list
  
'''RLPy.RStatus.Success''' Success to select object
+
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
  
'''RLPy.RStatus.Failure''' Fail while the object is not selectable or not exist
 
</div>
 
-----
 
===SelectObjects===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.SelectObjects ( kObjects )
+
avatars = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar )
 +
RLPy.RScene.SelectObjects(avatars)
 
</syntaxhighlight>
 
</syntaxhighlight>
Select objects in the scene.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kObjects''' [IN] List of the specified objects - RLPy.RIObject
+
=== Show ( spObject ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success to select object
+
Display an object in the scene.
 +
 
 +
See Also: [[#Hide ( spObject )|Hide]]
 +
 
 +
==== Parameters ====
 +
:'''spObject''' [IN] Object to be shown - [[IC_Python_API:RLPy_RIObject|RIObject]]
  
'''RLPy.RStatus.Failure''' Fail while the object is not selectable or not exist
 
</div>
 
-----
 
===Show===
 
 
<syntaxhighlight lang="Python">
 
<syntaxhighlight lang="Python">
RLPy.RScene.Show ( spObject )
+
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
 +
RLPy.RScene.Show(avatar)
 
</syntaxhighlight>
 
</syntaxhighlight>
Show object in the scene.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
 
'''spObject''' [IN] Object to be showed - RLPy.RIObject
 
</div>
 

Revision as of 19:40, 5 April 2020

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

Description

An animation project will usually contain all sorts of objects, such as characters, props, lights, cameras, particle systems, etc. The RScene class is used to manage these objects in the scene. It provides many functions for users to find and access these objects. RScene is a static class that can be used directly without having to create an instance. This class provides functions for finding objects by name or type, deleting object, showing / hiding objects, getting and setting selected object, and so on.

See Also: RIObject, RIAvatar, RIProp

Member Functions

ClearSelectObjects ( )

Deselect everything in the scene.

RLPy.RScene.ClearSelectObjects()

FindObject ( eType, strName )

Searches for an object by name and type. Returns the first object that fulfills the search criteria.

Parameters

eType [IN] Object type - RLPy.EObjectType
  • RLPy.EObjectType_Object
  • RLPy.EObjectType_Avatar
  • RLPy.EObjectType_Prop
  • RLPy.EObjectType_Camera
  • RLPy.EObjectType_Particle
  • RLPy.EObjectType_Light
  • RLPy.EObjectType_SpotLight
  • RLPy.EObjectType_PointLight
  • RLPy.EObjectType_DirectionalLight
strName [IN] Object name - string

Returns

First object that fulfills the search criteria - RIObject
# find avatar
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "avatar_name" )
print(type(avatar)) #RLPy.RIAvatar
# find prop
prop = RLPy.RScene.FindObject( RLPy.EObjectType_Prop, "prop_name" )
print(type(prop)) #RLPy.RIProp
# find camera
camera = RLPy.RScene.FindObject( RLPy.EObjectType_Camera, "camera_name" )
print(type(camera)) #RLPy.RICamera
# find particle
particle = RLPy.RScene.FindObject( RLPy.EObjectType_Particle, "particle_name" )
print(type(particle)) #RLPy.RIParticle

FindObjects ( args )

Searches for all objects that match by name and type.

See Also: FindObject()

Parameters

eType [IN] Object type - RLPy.EObjectType
  • RLPy.EObjectType_Object
  • RLPy.EObjectType_Avatar
  • RLPy.EObjectType_Prop
  • RLPy.EObjectType_Camera
  • RLPy.EObjectType_Particle
  • RLPy.EObjectType_Light
  • RLPy.EObjectType_SpotLight
  • RLPy.EObjectType_PointLight
  • RLPy.EObjectType_DirectionalLight
strName [IN] Object name - string

Returns

All objects that fullfill the search criteria - RIObject list
props = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop, "prop_name" )

GetAvatars ( eAvatarType )

Get all the characters in the scene. The search results can be filtered by avatar type.

See Also: FindObject, FindObjects()

Parameters

eAvatarType [IN] Character type - RLPy.EAvatarType
  • RLPy.EAvatarType_Standard
  • RLPy.EAvatarType_NonStandard
  • RLPy.EAvatarType_NonHuman
  • RLPy.EAvatarType_StandardSeries
  • RLPy.EAvatarType_All

Returns

All avatars that fulfill the search criteria - RIAvatar list
# Find standard avatars
avatars = RLPy.RScene.GetAvatars( RLPy.EAvatarType_Standard )

# Find avatars and props
result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar | RLPy.EObjectType_Prop, "same_name" )
print(len(result))
for i in range(len(result)):
   print(type(result[i]))  #RLPy.RIAvatar or IC_Python_API:RLPy_RIProp|RIProp
  
result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar | RLPy.EObjectType_Prop )
print(len(result)) # All avatars and props

GetProps ()

Get all the props in the scene.

See Also: FindObject, FindObjects

Returns

All props - RIObject list
props = RLPy.RScene.GetProps()

GetSelectedObjects ()

Get all the selected object in the scene. If no objects are selected then return an empty list.

See Also: SelectObject, SelectObjects, ClearSelectObjects

Returns

All selected objects - RIObject list
# get selected objects
selection_list = RLPy.RScene.GetSelectedObjects()
print(selection_list) #print selected objects

Hide ( spObject )

Hide an object in the scene.

See Also: Show

Parameters

spObject [IN] Object to be hidden - RIObject
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
RLPy.RScene.Hide(avatar)

RemoveObject ( spObject )

Remove an object from the scene.

See Also: Show

Parameters

spObject [IN] Object for removal - RIObject

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
RLPy.RScene.RemoveObject(avatar)

SelectObject ( spObject )

Select an object in the scene.

See Also: SelectObjects, ClearSelectObjects, GetSelectedObjects

Parameters

spObject [IN] Object to be selected - RIObject

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
RLPy.RScene.SelectObject(avatar)

SelectObjects ( kObjects )

Select several objects in the scene.

See Also: SelectObject, ClearSelectObjects, GetSelectedObjects

Parameters

kObjects [IN] Objects for seletion - RIObject list

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
avatars = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar )
RLPy.RScene.SelectObjects(avatars)

Show ( spObject )

Display an object in the scene.

See Also: Hide

Parameters

spObject [IN] Object to be shown - RIObject
avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
RLPy.RScene.Show(avatar)