Difference between revisions of "IC Python API:RLPy RIProp"
From Reallusion Wiki!
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
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 == | ||
+ | |||
+ | '''RIProp''' 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. | ||
+ | |||
+ | *Component of '''Scene''' modules. | ||
+ | *Inherits from [[IC_Python_API:RLPy_RIObject|RIObject]]. | ||
+ | *Related classes: [[IC_Python_API:RLPy_RIBase|RIBase]], [[IC_Python_API:RLPy_RIObject|RIObject]]. | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | <syntaxhighlight lang="Python"> | ||
+ | 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) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
# 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) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
#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) | ||
− | |||
− | |||
− | |||
− | |||
− | |||
#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> | ||
− | == | + | |
− | + | == Member Functions == | |
− | + | ||
− | + | === GetMaterialComponent ( self ) === | |
− | + | ||
− | + | Get the prop's Material Component, used to adjust the prop's material settings. | |
− | + | ||
− | + | See Also: [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]] | |
− | + | ||
− | + | ==== Returns ==== | |
− | + | :Material component of the prop - [[IC_Python_API:RLPy_RIMaterialComponent|RIMaterialComponent]] | |
− | + | ||
− | + | ||
− | + | ||
− | | | + | |
− | == | + | |
− | = | + | |
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box") |
+ | # get component | ||
+ | material_component = prop.GetMaterialComponent() | ||
+ | mesh_list = prop.GetMeshNames() | ||
+ | mesh_name = mesh_list[0] | ||
+ | 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 | + | |
− | ====Returns==== | + | === GetMorphComponent ( self ) === |
− | + | ||
− | + | Get the prop's Morph Component, used to adjust the prop's morph targets. | |
− | + | ||
− | + | See Also: [[IC_Python_API:RLPy_RIMorphComponent|RIMorphComponent]] | |
+ | |||
+ | ==== Returns ==== | ||
+ | :Morph component of the prop - [[IC_Python_API:RLPy_RIMorphComponent|RIMorphComponent]] | ||
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | 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> | ||
− | + | ||
− | === | + | === GetSkeletonComponent ( self ) === |
− | + | ||
− | + | Get the prop's Skeleton Component, used for retrieving bone or clip related data. | |
− | + | ||
− | === | + | See Also: [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]] |
+ | |||
+ | ==== Returns ==== | ||
+ | :Skeleton component for the prop - [[IC_Python_API:RLPy_RISkeletonComponent|RISkeletonComponent]] | ||
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | 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> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === IsDummy ( self ) === | |
− | + | ||
− | + | Check whether or not the prop is a Dummy object. | |
− | === | + | |
+ | See Also: [[#SetDummy ( self, bIsDummy )|SetDummy]] | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Whether or not the prop is a Dummy object - bool | ||
+ | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box") |
+ | # dummy | ||
+ | prop.SetDummy( True ) | ||
+ | is_dummy = prop.IsDummy() | ||
+ | print( is_dummy ) #True | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SetDummy ( self, bIsDummy ) === | |
− | + | ||
− | === | + | |
− | + | ||
− | + | Set the Dummy state for the prop. | |
+ | |||
+ | See Also: [[#IsDummy ( self )|IsDummy]] | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :bIsDummy [IN] Whether to set as Dummy object - bool | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box") |
+ | # dummy | ||
+ | prop.SetDummy( True ) | ||
+ | is_dummy = prop.IsDummy() | ||
+ | print( is_dummy ) #True | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | + | === SetPivot ( self, kPosition, kOrientation ) === | |
− | ' | + | Set the transforma values for the prop's pivot point. |
− | + | ||
− | + | ||
− | + | ||
− | + | ==== 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]] | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
− | |||
− | |||
− | |||
− | |||
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
− | RLPy. | + | 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> | ||
− | |||
− | |||
− | |||
− | + | === SetVisible ( self, kTime, bVisible ) === | |
− | ' | + | Set the prop's visibility at a given point in time. |
− | + | ||
− | + | ||
− | + | ||
− | + | ==== Parameters ==== | |
+ | :kTime [IN] Specifies the time to set visible - [[IC_Python_API:RLPy_RTime|RTime]] | ||
+ | :bVisible [IN] Visible status - bool | ||
− | + | ==== Returns ==== | |
− | </ | + | :Success - RLPy.RStatus.Success |
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="Python"> | ||
+ | prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box") | ||
+ | ret = prop.SetVisible( RLPy.RTime( 67 ), false ) | ||
+ | print(ret) | ||
+ | </syntaxhighlight> |
Revision as of 21:49, 5 April 2020
- Main article: Modules.
- Last modified: 04/5/2020
Description
RIProp 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.
Examples
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
# get Name
prop_name = prop.GetName()
print(prop_name) # Box
# set name
prop.SetName( "new_name" )
# set Transform key
control = prop.GetControl("Transform")
transform = RLPy.RTransform.IDENTITY
transform.T().x = 100.0
transform.T().y = 100.0
transform.T().z = 100.0
control.SetValue(RLPy.RTime(0), transform)
# set Parent
result = prop.SetParent(prop2)
result = prop.SetParent(None) #detach from parent
# link to & unlink
result = prop.LinkTo(prop2, RLPy.RTime(0))
result = prop.UnLink(RLPy.RTime(0))
#get bound
ret_max = RLPy.RVector3()
ret_center = RLPy.RVector3()
ret_min = RLPy.RVector3()
ret = prop.GetBounds( ret_max, ret_center, ret_min )
print(ret)
#get pivot
ret_pos = RLPy.RVector3()
ret_rot = RLPy.RVector3()
prop.GetPivot( ret_pos, ret_rot )
print(ret)
#clone object
clone_prop = prop.Clone()
print( clone_prop )
#is selected
RLPy.RScene.SelectObject(prop)
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
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
# get component
material_component = prop.GetMaterialComponent()
mesh_list = prop.GetMeshNames()
mesh_name = mesh_list[0]
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))
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
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")
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
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)
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
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
# dummy
prop.SetDummy( True )
is_dummy = prop.IsDummy()
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
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
# dummy
prop.SetDummy( True )
is_dummy = prop.IsDummy()
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
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)
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
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box")
ret = prop.SetVisible( RLPy.RTime( 67 ), false )
print(ret)