Hitting some API call issues, please advise

Hi there,

I’m trying to do a few simple things with API but it seems that most of online samples are for iClone 7 while I’m using iClone 8. Documentation is also not always helping so I’m hoping someone here could provide advice for these few things I’m trying to do.

  1. How to manipulate the scene’s avatar Transform properly at frame 0? I assume it has something to do with DataBlock but I failed to update it

  2. Add/manipulate a scene prop so it gets attached to the scene’s avatar

  3. Change render frames for RenderVideo. Or is that always hardcoded to 60?

Figured out how to do everything I needed. It was all in documentation but all over the place between iClone 7 and 8 docs and examples

Hi Hexer

  • For avatar transform at frame 0, use GetControl("Transform") , create an RTransformKey , and call AddKey(key, RGlobal.GetFps()) .
  • For attaching a prop, SetParent(avatar) is the correct basic parenting operation. Then set the prop’s local transform if you need an offset relative to the avatar.
  • RenderVideo() is not fixed to 60 frames. The frame range is controlled by the start_time and end_time arguments you pass in.
import RLPy
import os
import sys
import tempfile

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

def run_script():    
    
    # 1. manipulate the scene’s avatar Transform properly at frame 0
    avatar_list = RLPy.RScene.GetAvatars()
    if len(avatar_list) == 0:
        print ("please load an avatar first.")
        return
       
    avatar = avatar_list[0]
    print (avatar.GetName())
    
    transform_control = avatar.GetControl("Transform")
    transform_db = transform_control.GetDataBlock()

    trans = avatar.LocalTransform()
    trans.T().SetX(100)
    trans.R().SetX(0.2588)
    trans.R().SetW(0.9659)
    time_obj = RLPy.RTime.FromValue(0)
    key_frame = RLPy.RTransformKey()
    key_frame.SetTime(time_obj)
    key_frame.SetTransform(trans)
    transform_control.AddKey(key_frame)
    transform_control.SetKeyTransition(time_obj, RLPy.ETransitionType_Linear, 1.0)
    RLPy.RGlobal.ObjectModified(avatar, RLPy.EObjectModifiedType_Transform|RLPy.EObjectModifiedType_Attribute|RLPy.EObjectModifiedType_Motion)

    # 2. attach a prop to the avatar
    prop_list = RLPy.RScene.GetProps()
    if len(prop_list) <= 1:
        print ("please load a prop first.")
        return
    prop = prop_list[1]
    print (prop.GetName())
    ret = prop.SetParent(avatar)

    # 3.Change render frames for RenderVideo
    excute_parent_path = os.path.abspath(os.path.join(sys.executable, os.pardir))
    temp_dir = tempfile.gettempdir()
    filePath = temp_dir + "//Test.mp4"
    srt_time = RLPy.IndexedFrameTime(0, RLPy.RGlobal.GetFps())
    end_time = RLPy.IndexedFrameTime(60, RLPy.RGlobal.GetFps())
    result = RLPy.RGlobal.RenderVideo(srt_time, end_time, filePath)

Hi Johnny, thank you kindly for helpful answers and examples!

I’m wondering do you have any plans on fixing function RenderImageSequence to work properly in iClone 9?

At the moment it produces cca 15% vertically squashed renders no matter the camera or project settings.

Hi Hexer,

Thank you for reporting this.

I tested the RenderImageSequence API on our side, and the output result appears to be the same as rendering from the Render panel with Image and Sequence selected. I did not see the 15% vertical squash issue in the rendered output.
import RLPy

def run_script():
    print ("Render Image~")
    srt_time = RLPy.IndexedFrameTime(0, RLPy.RGlobal.GetFps())
    end_time = RLPy.IndexedFrameTime(30, RLPy.RGlobal.GetFps())
    RLPy.RGlobal.RenderImageSequence(srt_time, end_time, "D:\\Temp\\Out.png")

Could you please provide more details about the issue you are seeing with RenderImageSequence in iClone 9?
Once we have the screenshots and sample rendered files, we can investigate the issue more accurately.

1 Like

Hi Johnny, thank you very much for your helpful insight!

After I followed your instructions on a brand new project, the squashing disappeared and everything rendered proportionally. However, I manged to pinpoint the exact cause of the earlier issue.

Whenever I use any other Frame Size besides HD 1080, Ultra HD or Custom (set at those two), the output render gets somehow squashed / distorted. I’m specifically using Custom 4:3 640x480 for my sequenced renderer and it’s rendering squashed files.

No issues at all if I just use RenderImage but that one’s very slow since I have to jump every frame and it seems to be internally “restarting the system” so it takes a while to finish.

Hope this helps in debugging!