Difference between revisions of "IC Python API:RLPy RScene"
Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} == Detailed Description == This class providing methods to access the current scene. <span style="background:#ffcccc...") |
Chuck (RL) (Talk | contribs) m |
||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | == | + | {{last_modified}} |
− | + | ||
− | < | + | == Description == |
+ | |||
+ | An animation project will usually contain all sorts of objects, such as characters, props, lights, cameras, particle systems, etc. The [[IC_Python_API:RLPy_RScene|RScene]] class is used to manage these objects in the scene. It provides many functions for users to find and access these objects. [[IC_Python_API:RLPy_RScene|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" line='line'> | ||
+ | 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" line='line'> | ||
# 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> | ||
− | + | === FindObjects ( args ) === | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | Searches for all objects that match by name and type. | |
− | + | ||
+ | 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 | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | props = RLPy.RScene.FindObjects( RLPy.EObjectType_Prop, "prop_name" ) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === GetAvatars ( eAvatarType ) === | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | Get all the characters in the scene. The search results can be filtered by avatar type. | |
− | + | ||
− | ==== | + | See Also: [[#FindObject ( eType, strName )|FindObject]], [[#FindObjects ( args )|FindObjects]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | + | :'''eAvatarType''' [IN] Character type - RLPy.EAvatarType | |
− | === | + | :*RLPy.EAvatarType_Standard |
− | <syntaxhighlight lang=" | + | :*RLPy.EAvatarType_NonStandard |
− | RLPy.RScene.FindObjects ( | + | :*RLPy.EAvatarType_NonHuman |
+ | :*RLPy.EAvatarType_StandardSeries | ||
+ | :*RLPy.EAvatarType_All | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :All avatars that fulfill the search criteria - [[IC_Python_API:RLPy_RIAvatar|RIAvatar]] list | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # 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> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === GetProps ( ) === | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | Get all the props in the scene. | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | Get all | + | |
− | + | ||
− | + | ||
− | + | See Also: [[#FindObject ( eType, strName )|FindObject]], [[#FindObjects ( args )|FindObjects]] | |
− | + | ||
− | + | ==== Returns ==== | |
− | + | :All props - [[IC_Python_API:RLPy_RIObject|RIObject]] list | |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | props = RLPy.RScene.GetProps() | |
− | ====Returns==== | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | <syntaxhighlight lang=" | + | |
− | RLPy.RScene.GetProps ( ) | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | Get all | + | |
− | + | === GetSelectedObjects ( ) === | |
− | ====Returns==== | + | |
− | + | Get all the selected object in the scene. If no objects are selected then return an empty list. | |
− | + | ||
− | + | See Also: [[#SelectObject ( spObject )|SelectObject]], [[#SelectObjects ( kObjects )|SelectObjects]], [[#ClearSelectObjects ( )|ClearSelectObjects]] | |
− | + | ||
− | <syntaxhighlight lang=" | + | ==== Returns ==== |
− | RLPy.RScene.GetSelectedObjects ( ) | + | :All selected objects - [[IC_Python_API:RLPy_RIObject|RIObject]] list |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | # get selected objects | ||
+ | selection_list = RLPy.RScene.GetSelectedObjects() | ||
+ | print(selection_list) #print selected objects | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | '''spObject''' [IN] Object to be | + | === Hide ( spObject ) === |
− | + | ||
− | + | Hide an object in the scene. | |
− | + | ||
− | <syntaxhighlight lang=" | + | See Also: [[#Show ( spObject )|Show]] |
− | RLPy.RScene. | + | |
+ | ==== Parameters ==== | ||
+ | :'''spObject''' [IN] Object to be hidden - [[IC_Python_API:RLPy_RIObject|RIObject]] | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" ) | ||
+ | RLPy.RScene.Hide(avatar) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === RemoveObject ( spObject ) === | |
− | + | ||
− | + | ||
− | + | ||
− | + | Remove an object from the scene. | |
− | ''' | + | See Also: [[#Show ( spObject )|Show]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''spObject''' [IN] Object for removal - [[IC_Python_API:RLPy_RIObject|RIObject]] |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RScene. | + | ==== Returns ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" ) | ||
+ | RLPy.RScene.RemoveObject(avatar) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | '''spObject''' [IN] | + | === SelectObject ( spObject ) === |
− | + | ||
− | + | 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 | ||
− | '' | + | <syntaxhighlight lang="python" line='line'> |
− | + | avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" ) | |
− | + | RLPy.RScene.SelectObject(avatar) | |
− | + | ||
− | + | ||
− | RLPy.RScene. | + | |
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SelectObjects ( kObjects ) === | |
− | + | ||
− | + | ||
− | + | ||
− | + | Select several objects in the scene. | |
− | ''' | + | See Also: [[#SelectObject ( spObject )|SelectObject]], [[#ClearSelectObjects ( )|ClearSelectObjects]], [[#GetSelectedObjects ( )|GetSelectedObjects]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''kObjects''' [IN] Objects for seletion - [[IC_Python_API:RLPy_RIObject|RIObject]] list |
− | <syntaxhighlight lang=" | + | |
− | RLPy.RScene. | + | ==== Returns ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | avatars = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar ) | ||
+ | RLPy.RScene.SelectObjects(avatars) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | '''spObject''' [IN] Object to be | + | === Show ( spObject ) === |
− | </ | + | |
+ | Display an object in the scene. | ||
+ | |||
+ | See Also: [[#Hide ( spObject )|Hide]] | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :'''spObject''' [IN] Object to be shown - [[IC_Python_API:RLPy_RIObject|RIObject]] | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" ) | ||
+ | RLPy.RScene.Show(avatar) | ||
+ | </syntaxhighlight> |
Latest revision as of 23:45, 14 April 2020
Contents
- 1 Description
- 2 Member Functions
- Main article: Modules.
- Last modified: 04/14/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.
1 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
1 # find avatar
2 avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "avatar_name" )
3 print(type(avatar)) #RLPy.RIAvatar
4 # find prop
5 prop = RLPy.RScene.FindObject( RLPy.EObjectType_Prop, "prop_name" )
6 print(type(prop)) #RLPy.RIProp
7 # find camera
8 camera = RLPy.RScene.FindObject( RLPy.EObjectType_Camera, "camera_name" )
9 print(type(camera)) #RLPy.RICamera
10 # find particle
11 particle = RLPy.RScene.FindObject( RLPy.EObjectType_Particle, "particle_name" )
12 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
1 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
1 # Find standard avatars
2 avatars = RLPy.RScene.GetAvatars( RLPy.EAvatarType_Standard )
3
4 # Find avatars and props
5 result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar | RLPy.EObjectType_Prop, "same_name" )
6 print(len(result))
7 for i in range(len(result)):
8 print(type(result[i])) #RLPy.RIAvatar or IC_Python_API:RLPy_RIProp|RIProp
9
10 result = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar | RLPy.EObjectType_Prop )
11 print(len(result)) # All avatars and props
GetProps ( )
Get all the props in the scene.
See Also: FindObject, FindObjects
Returns
- All props - RIObject list
1 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
1 # get selected objects
2 selection_list = RLPy.RScene.GetSelectedObjects()
3 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
1 avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
2 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
1 avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
2 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
1 avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
2 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
1 avatars = RLPy.RScene.FindObjects( RLPy.EObjectType_Avatar )
2 RLPy.RScene.SelectObjects(avatars)
Show ( spObject )
Display an object in the scene.
See Also: Hide
Parameters
- spObject [IN] Object to be shown - RIObject
1 avatar = RLPy.RScene.FindObject( RLPy.EObjectType_Avatar, "name" )
2 RLPy.RScene.Show(avatar)