Access the Switcher thru API?

I don’t see any way to access the Camera Switcher / Switch Keys / Camera Selection on the timeline via the API. Is it possible?

Yes — it is possible via the RLPy.RScene camera switcher APIs.

You can set, clear, and query Camera Switcher keys on the timeline with APIs like these:

import RLPy

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

def run_script():
	camera_list = RLPy.RScene.FindObjects( RLPy.EObjectType_Camera )
	camera = camera_list[0]

	RLPy.RScene.ClearSwitchCameraKeys()
	set_time = RLPy.IndexedFrameTime(40, RLPy.RGlobal.GetFps())
	RLPy.RScene.AddSwitchCameraKey(set_time, camera)
	
	camera_list = RLPy.RScene.GetSwitchCameraFrameIndexs(RLPy.RGlobal.GetFps())
	print(camera_list[0][0].GetName())	#camera object
	print(camera_list[0][1])	        #frame
	
	RLPy.RScene.SetCurrentCamera( None )    # Set Current Camera to Switch

Thanks Johnny.

When I try to just get the existing camera/frame list (not Clear or Create a New Key), I get the following error:

Function: _call_with_frames_removed

Can you explain the following instruction a little more?

camera_list = RLPy.RScene.GetSwitchCameraFrameIndexs(RLPy.RGlobal.GetFps())

That seems to be where the problem pops up (if a frame hasn’t been previously specified). So how to pull the list if you don’t know the frames ahead of time?

1 Like