IC Python API:Transformation Key

From Reallusion Wiki!
Revision as of 03:01, 22 April 2019 by Chuck (RL) (Talk | contribs) (Loading a Test Prop)

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 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:


Animating the Box