Difference between revisions of "IC Python API:Transformation Key"
From Reallusion Wiki!
Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Samples|RL Python Samples}} This article focuses on animating a prop by keying its transformation. This is an alternative to the usu...") |
Chuck (RL) (Talk | contribs) m (→Loading a Test Prop) |
||
Line 31: | Line 31: | ||
== Loading a Test Prop == | == Loading a Test Prop == | ||
− | Let's | + | Let's start by loading in a box object for the purpose of animation. |
<syntaxhighlight lang="Python"> | <syntaxhighlight lang="Python"> | ||
Line 43: | Line 43: | ||
RLPy.RFileIO.LoadFile( | RLPy.RFileIO.LoadFile( | ||
ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp") | ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp") | ||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
+ | |||
+ | This gives us the following result: | ||
+ | |||
+ | |||
+ | |||
+ | == Animating the Box == |
Revision as of 03:01, 22 April 2019
- Main article: RL Python Samples.
This article focuses on animating a prop by keying its transformation. This is an alternative to the usual method of animating objects by setting data on transformational components like below:
data_block = prop.GetControl("Transform").GetDataBlock()
data_block.SetData("Position/PositionX", RLPy.RTime(0), RLPy.RVariant(100))
data_block.SetData("Position/PositionY", RLPy.RTime(0), RLPy.RVariant(0))
data_block.SetData("Position/PositionZ", RLPy.RTime(0), RLPy.RVariant(50))
Necessary Modules
Besides the RLPy standard module, we'll need two system based modules to load a prop from a directory with the likes of os and winreg
import RLPy
import os
import winreg
os
The os module provides a portable way of using operating system dependent functionality.
winreg
winreg offers functions that exposes the Windows registry API to Python.
Loading a Test Prop
Let's start by loading in a box object for the purpose of animation.
# Get the iClone 7 default template path
registry = winreg.ConnectRegistry(None, winreg.HKEY_LOCAL_MACHINE)
rawKey = winreg.OpenKey(registry, r"SOFTWARE\Reallusion\iClone\7.0")
ic_template_path = os.path.abspath(
winreg.QueryValueEx(rawKey, "Template Data")[0])
# Load Box_001.iProp
RLPy.RFileIO.LoadFile(
ic_template_path + "//iClone Template//Props//3D Blocks//Box_001.iProp")
This gives us the following result: