IC Python API:Transformation Key

From Reallusion Wiki!
Revision as of 02:53, 22 April 2019 by 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...")

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
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

# 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")

# Get the imported box
prop = RLPy.RScene.FindObject(RLPy.EObjectType_Prop, "Box_001")