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

From Reallusion Wiki!
Jump to: navigation, search
m
m
 
(10 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}}
==Inheritance==
+
{{last_modified}}
This class inherits public member functions from:
+
*[[IC_Python_API:RLPy_RIObject|RLPy.RIObject]]
+
*[[IC_Python_API:RLPy_RIBase|RLPy.RIBase]]
+
==Detailed Description==
+
This class is the interface to props in the scene.
+
It provides methods to access various parts of an prop such as its
+
name, transformation, etc. All methods of this class are implemented by
+
the system. <syntaxhighlight lang="Python">
+
import RLPy
+
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
+
  
 +
== Description ==
 +
 +
This class can be used to access basic information of prop objects and obtain the control or components of the prop to modify its the transform values and materials.
 +
 +
=== Inheritance ===
 +
 +
[[IC_Python_API:RLPy_RIBase|RIBase]] > [[IC_Python_API:RLPy_RIObject|RIObject]] > [[IC_Python_API:RLPy_RIProp|RIProp]]
 +
 +
=== Examples ===
 +
 +
<syntaxhighlight lang="python" line='line'>
 +
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 
# get Name
 
# get Name
 
prop_name = prop.GetName()
 
prop_name = prop.GetName()
print(prop_name) # Box
+
print(prop_name)               # Box
 
+
 
# set name
 
# set name
 
prop.SetName( "new_name" )
 
prop.SetName( "new_name" )
 
 
# set Transform key
 
# set Transform key
 
control = prop.GetControl("Transform")
 
control = prop.GetControl("Transform")
Line 27: Line 27:
 
transform.T().z = 100.0
 
transform.T().z = 100.0
 
control.SetValue(RLPy.RTime(0), transform)
 
control.SetValue(RLPy.RTime(0), transform)
 
# get component
 
skeleton = prop.GetSkeletonComponent()
 
print(skeleton.GetClipCount())
 
 
# set visible key
 
prop.SetVisible(RLPy.RTime(600), False)
 
  
prop2 = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box2")
 
 
# set Parent
 
# set Parent
 
result = prop.SetParent(prop2)
 
result = prop.SetParent(prop2)
 
result = prop.SetParent(None) #detach from parent
 
result = prop.SetParent(None) #detach from parent
 
+
# link to & unlink
# link to & unlink
+
 
result = prop.LinkTo(prop2, RLPy.RTime(0))
 
result = prop.LinkTo(prop2, RLPy.RTime(0))
 
result = prop.UnLink(RLPy.RTime(0))
 
result = prop.UnLink(RLPy.RTime(0))
 
 
#get bound
 
#get bound
 
ret_max = RLPy.RVector3()
 
ret_max = RLPy.RVector3()
Line 50: Line 40:
 
ret = prop.GetBounds( ret_max, ret_center, ret_min )
 
ret = prop.GetBounds( ret_max, ret_center, ret_min )
 
print(ret)
 
print(ret)
 
#set pivot
 
pos = RLPy.RVector3( 10, 10, 10 )
 
rot = RLPy.RVector3( 0, 0, 0 )
 
ret = prop.SetPivot( pos, rot )
 
print(ret)
 
 
 
#get pivot
 
#get pivot
 
ret_pos = RLPy.RVector3()
 
ret_pos = RLPy.RVector3()
Line 62: Line 45:
 
prop.GetPivot( ret_pos, ret_rot )
 
prop.GetPivot( ret_pos, ret_rot )
 
print(ret)
 
print(ret)
 
# dummy
 
prop.SetDummy( True )
 
is_dummy = prop.IsDummy()
 
print( is_dummy ) #True
 
  
 
#clone object
 
#clone object
 
clone_prop = prop.Clone()
 
clone_prop = prop.Clone()
 
print( clone_prop )
 
print( clone_prop )
 
 
#is selected
 
#is selected
 
RLPy.RScene.SelectObject(prop)
 
RLPy.RScene.SelectObject(prop)
 
print(prop.IsSelected()) #True
 
print(prop.IsSelected()) #True
 
</syntaxhighlight>
 
</syntaxhighlight>
==Operators==
+
 
This class supports the following operators:
+
== Member Functions ==
{| class="wikitable"
+
 
!Member
+
=== GetMaterialComponent ( self ) ===
!Operation
+
 
!Syntax
+
Get the prop's Material Component, used to adjust the prop's material settings.
!Description
+
 
!Example
+
See Also: [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]]
|-
+
 
! scope="row"|__eq__
+
==== Returns ====
|Equality
+
:Material component of the prop - [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]]
|a == b
+
 
|If the values of two operands are equal, then the condition becomes true.
+
<syntaxhighlight lang="python" line='line'>
|(a == b) is not true.
+
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
|}
+
# get component
==Member Functions==
+
material_component = prop.GetMaterialComponent()
===GetMaterialComponent===
+
mesh_list = prop.GetMeshNames()
<syntaxhighlight lang="Python">
+
mesh_name = mesh_list[0]
RLPy.RIProp.GetMaterialComponent ( self )
+
material_list = material_component.GetMaterialNames(mesh_name)
 +
material_name = material_list[0]
 +
# Modify material light - ambient channel
 +
ambient_color = RLPy.RRgb.RED
 +
# Create Key
 +
key = RLPy.RKey()
 +
key.SetTime(RLPy.RTime(1200))
 +
key.SetTransitionType(RLPy.ETransitionType_Linear)
 +
key.SetTransitionStrength(50)
 +
material_component.AddAmbientKey(key, mesh_name, material_name, ambient_color)
 +
print(material_component.GetAmbientColor(mesh_name, material_name))
 
</syntaxhighlight>
 
</syntaxhighlight>
Get material component of the object.
+
 
====Returns====
+
=== GetMorphComponent ( self ) ===
<div style="margin-left: 2em;">Pointer of the RIMaterialComponent object - RLPy.RIMaterialComponent
+
 
</div>
+
Get the prop's Morph Component, used to adjust the prop's morph targets.
-----
+
 
===GetMorphComponent===
+
See Also: [[IC_Python_API:RLPy_RIMorphComponent|RIMorphComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIProp.GetMorphComponent ( self )
+
==== Returns ====
 +
:Morph component of the prop - [[IC_Python_API:RLPy_RIMorphComponent|RIMorphComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 +
# get component
 +
morph_component = prop.GetMorphComponent()
 +
result = morph_component.AddKey( "your_mesh_name", "your_morph_name", RLPy.RTime(67),  0.5, False, False )
 +
 +
f_ret_weight = 0
 +
return_list = morph_component.GetWeight( "your_mesh_name", "your_morph_name", RLPy.RTime(67), f_ret_weight )
 +
f_ret_weight = return_list[1]
 +
print(f_ret_weight) # is 0.5
 +
 +
result = morph_component.RemoveAllKeys("your_mesh_name", "your_morph_name")
 +
morph_names = morph_component.GetMorphNames("your_mesh_name")
 
</syntaxhighlight>
 
</syntaxhighlight>
Get morph component of the object.
+
 
====Returns====
+
=== GetSkeletonComponent ( self ) ===
<div style="margin-left: 2em;">Pointer of the RIMorphComponent object - RLPy.RIMorphComponent
+
 
</div>
+
Get the prop's Skeleton Component, used for retrieving bone or clip related data.
-----
+
 
===GetSkeletonComponent===
+
See Also: [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]]
<syntaxhighlight lang="Python">
+
 
RLPy.RIProp.GetSkeletonComponent ( self )
+
==== Returns ====
 +
:Skeleton component for the prop - [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]]
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 +
# get component
 +
bone = prop.GetSkeletonComponent()
 +
print(bone.GetClip(0))
 +
 +
# get selected bone
 +
selected_bones = bone.GetSelectedBones()
 +
print(len(selected_bones))
 +
 +
# get root bone
 +
root_bone = bone.GetRootBone()
 +
print(root_bone)
 
</syntaxhighlight>
 
</syntaxhighlight>
Get bone root of the object.
 
====Returns====
 
<div style="margin-left: 2em;">Bone root - RLPy.RISkeletonComponent
 
</div>
 
-----
 
===IsDummy===
 
<syntaxhighlight lang="Python">
 
RLPy.RIProp.IsDummy ( self )
 
</syntaxhighlight>
 
Check if prop state is dummy.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Return Values====
 
<div style="margin-left: 2em;">
 
  
'''Bool''' value true if prop state is dummy; otherwise false.
+
=== IsDummy ( self ) ===
</div>
+
 
-----
+
Check whether or not the prop is a Dummy object.
===SetDummy===
+
 
<syntaxhighlight lang="Python">
+
See Also: [[#SetDummy ( self, bIsDummy )|SetDummy]]
RLPy.RIProp.SetDummy ( self, bIsDummy )
+
 
 +
==== Returns ====
 +
:Whether or not the prop is a Dummy object - bool
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 +
# dummy
 +
prop.SetDummy( True )
 +
is_dummy = prop.IsDummy()
 +
print( is_dummy ) #True
 
</syntaxhighlight>
 
</syntaxhighlight>
Set the prop state whether its dummy or not.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''bIsDummy''' [IN] takes prop state as bool value : true or false - bool
+
=== SetDummy ( self, bIsDummy ) ===
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
Set the Dummy state for the prop.
  
'''RLPy.RStatus.Failure''' Fail
+
See Also: [[#IsDummy ( self )|IsDummy]]
</div>
+
 
-----
+
==== Parameters ====
===SetPivot===
+
:'''bIsDummy''' [IN] Whether to set as Dummy object - bool
<syntaxhighlight lang="Python">
+
 
RLPy.RIProp.SetPivot ( self, kPosition, kOrientation )
+
==== Returns ====
 +
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 +
# dummy
 +
prop.SetDummy( True )
 +
is_dummy = prop.IsDummy()
 +
print( is_dummy ) #True
 
</syntaxhighlight>
 
</syntaxhighlight>
This function lets you re-position and re-orient the current object's pivot.
 
<span style="background:#ffcccc">( Experimental API )</span>
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kPosition''' [IN] pivot position - RLPy.RVector3f
+
=== SetPivot ( self, kPosition, kOrientation ) ===
  
'''kOrientation''' [IN] pivot orientation - RLPy.RVector3f
+
Set the transforma values for the prop's pivot point.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kPosition''' [IN] Pivot position for the prop - [[IC_Python_API:RLPy_RVector3|RVector3]]
 +
:'''kOrientation''' [IN] Pivot orientation for the prop - [[IC_Python_API:RLPy_RVector3|RVector3]]
  
'''RLPy.RStatus.Failure''' Fail
+
==== Returns ====
</div>
+
:Success - RLPy.RStatus.Success
-----
+
:Failure - RLPy.RStatus.Failure
===SetVisible===
+
 
<syntaxhighlight lang="Python">
+
<syntaxhighlight lang="python" line='line'>
RLPy.RIProp.SetVisible ( self, kTime, bVisible )
+
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 +
#set pivot
 +
pos = RLPy.RVector3( 10, 10, 10 )
 +
rot = RLPy.RVector3( 0, 0, 0 )
 +
ret = prop.SetPivot( pos, rot )
 +
print(ret)
 
</syntaxhighlight>
 
</syntaxhighlight>
( Experimental Function ) Set visible status
 
====Parameters====
 
<div style="margin-left: 2em;">
 
  
'''kTime''' [IN] Specifies the time to set visible - RLPy.RTime
+
=== SetVisible ( self, kTime, bVisible ) ===
  
'''bVisible''' [IN] Visible status - bool
+
Set the prop's visibility at a given point in time.
</div>
+
====Return Values====
+
<div style="margin-left: 2em;">
+
  
'''RLPy.RStatus.Success''' Success
+
==== Parameters ====
 +
:'''kTime''' [IN] Specifies the time to set visible - [[IC_Python_API:RLPy_RTime|RTime]]
 +
:'''bVisible''' [IN] Visible status - bool
  
'''RLPy.RStatus.Failure''' Fail
+
==== Returns ====
</div>
+
:Success - RLPy.RStatus.Success
 +
:Failure - RLPy.RStatus.Failure
 +
 
 +
<syntaxhighlight lang="python" line='line'>
 +
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 +
ret = prop.SetVisible( RLPy.RTime( 67 ), false )
 +
print(ret)
 +
</syntaxhighlight>

Latest revision as of 23:48, 14 April 2020

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

Description

This class can be used to access basic information of prop objects and obtain the control or components of the prop to modify its the transform values and materials.

Inheritance

RIBase > RIObject > RIProp 

Examples

 1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 2 # get Name
 3 prop_name = prop.GetName()
 4 print(prop_name)                # Box
 5 # set name
 6 prop.SetName( "new_name" )
 7 # set Transform key
 8 control = prop.GetControl("Transform")
 9 transform = RLPy.RTransform.IDENTITY
10 transform.T().x = 100.0
11 transform.T().y = 100.0
12 transform.T().z = 100.0
13 control.SetValue(RLPy.RTime(0), transform)
14 
15 # set Parent
16 result = prop.SetParent(prop2)
17 result = prop.SetParent(None) #detach from parent
18 # link to &  unlink
19 result = prop.LinkTo(prop2, RLPy.RTime(0))
20 result = prop.UnLink(RLPy.RTime(0))
21 #get bound
22 ret_max = RLPy.RVector3()
23 ret_center = RLPy.RVector3()
24 ret_min = RLPy.RVector3()
25 ret = prop.GetBounds( ret_max, ret_center, ret_min )
26 print(ret)
27 #get pivot
28 ret_pos = RLPy.RVector3()
29 ret_rot = RLPy.RVector3()
30 prop.GetPivot( ret_pos, ret_rot )
31 print(ret)
32 
33 #clone object
34 clone_prop = prop.Clone()
35 print( clone_prop )
36 #is selected
37 RLPy.RScene.SelectObject(prop)
38 print(prop.IsSelected()) #True

Member Functions

GetMaterialComponent ( self )

Get the prop's Material Component, used to adjust the prop's material settings.

See Also: RIMaterialComponent

Returns

Material component of the prop - RIMaterialComponent
 1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 2 # get component
 3 material_component = prop.GetMaterialComponent()
 4 mesh_list = prop.GetMeshNames()
 5 mesh_name = mesh_list[0]
 6 material_list = material_component.GetMaterialNames(mesh_name)
 7 material_name = material_list[0]
 8 # Modify material light - ambient channel
 9 ambient_color = RLPy.RRgb.RED
10 # Create Key
11 key = RLPy.RKey()
12 key.SetTime(RLPy.RTime(1200))
13 key.SetTransitionType(RLPy.ETransitionType_Linear)
14 key.SetTransitionStrength(50)
15 material_component.AddAmbientKey(key, mesh_name, material_name, ambient_color)
16 print(material_component.GetAmbientColor(mesh_name, material_name))

GetMorphComponent ( self )

Get the prop's Morph Component, used to adjust the prop's morph targets.

See Also: RIMorphComponent

Returns

Morph component of the prop - RIMorphComponent
 1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 2 # get component
 3 morph_component = prop.GetMorphComponent()
 4 result = morph_component.AddKey( "your_mesh_name", "your_morph_name", RLPy.RTime(67),  0.5, False, False )
 5  
 6 f_ret_weight = 0
 7 return_list = morph_component.GetWeight( "your_mesh_name", "your_morph_name", RLPy.RTime(67), f_ret_weight )
 8 f_ret_weight = return_list[1]
 9 print(f_ret_weight) # is 0.5
10  
11 result = morph_component.RemoveAllKeys("your_mesh_name", "your_morph_name")
12 morph_names = morph_component.GetMorphNames("your_mesh_name")

GetSkeletonComponent ( self )

Get the prop's Skeleton Component, used for retrieving bone or clip related data.

See Also: RISkeletonComponent

Returns

Skeleton component for the prop - RISkeletonComponent
 1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
 2 # get component
 3 bone = prop.GetSkeletonComponent()
 4 print(bone.GetClip(0))
 5  
 6 # get selected bone
 7 selected_bones = bone.GetSelectedBones()
 8 print(len(selected_bones))
 9  
10 # get root bone
11 root_bone = bone.GetRootBone()
12 print(root_bone)

IsDummy ( self )

Check whether or not the prop is a Dummy object.

See Also: SetDummy

Returns

Whether or not the prop is a Dummy object - bool
1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
2 # dummy
3 prop.SetDummy( True )
4 is_dummy = prop.IsDummy()
5 print( is_dummy )  #True

SetDummy ( self, bIsDummy )

Set the Dummy state for the prop.

See Also: IsDummy

Parameters

bIsDummy [IN] Whether to set as Dummy object - bool

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
2 # dummy
3 prop.SetDummy( True )
4 is_dummy = prop.IsDummy()
5 print( is_dummy )  #True

SetPivot ( self, kPosition, kOrientation )

Set the transforma values for the prop's pivot point.

Parameters

kPosition [IN] Pivot position for the prop - RVector3
kOrientation [IN] Pivot orientation for the prop - RVector3

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
2 #set pivot
3 pos = RLPy.RVector3( 10, 10, 10 )
4 rot = RLPy.RVector3( 0, 0, 0 )
5 ret = prop.SetPivot( pos, rot )
6 print(ret)

SetVisible ( self, kTime, bVisible )

Set the prop's visibility at a given point in time.

Parameters

kTime [IN] Specifies the time to set visible - RTime
bVisible [IN] Visible status - bool

Returns

Success - RLPy.RStatus.Success
Failure - RLPy.RStatus.Failure
1 prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
2 ret = prop.SetVisible( RLPy.RTime( 67 ), false )
3 print(ret)