Quick code example: How to change the speed of an EXPRESSION CLIP of a character in iClone 8 Python API


https://forum.reallusion.com/Topic539084.aspx
Print Topic | Close Window

By mrtobycook - 2 Years Ago
Hi all,
If you have an avatar in your scene (a character), and it has an EXPRESSION CLIP on it (NOT a motion clip - which is the bone animation, but an EXPRESSION CLIP that has morph target animation aka blendshape animation), how do you change the speed of it?
It's quite straightforward, but there's no examples specifically on the wiki at the moment, and I keep forgetting how to do it after a while and then come back and wish there was. :-)
So...

import RLPy
import os

rl_plugin_info = {"ap": "iClone", "ap_version": "8.0"}

def get_yourcurrentlyselected_obj():
    global ic_selected_obj
    if RLPy.RScene.GetSelectedObjects():
        ic_selected_objs = RLPy.RScene.GetSelectedObjects()
        ic_selected_obj = ic_selected_objs[0]
    else:
        ic_selected_obj = None

get_yourcurrentlyselected_obj()

cur_face_component = ic_selected_obj.GetFaceComponent()

clip_index = 0
cur_clip = cur_face_component.GetClip(clip_index)

if (cur_clip != None):
    print("Ok now changing the speed of the clip...")
    cur_clip.SetSpeed(0.5)
    RLPy.RGlobal.ObjectModified(ic_selected_obj, RLPy.EObjectModifiedType_Attribute)


So basically you use FACE COMPONENT - which allows you to 'GetClip' with it.
In the example above, the clip is at index 0. You may have to loop through and try to find which index it's on - it may not always be at zero.

Toby