iClone Event System

iClone Events are a way of allowing user driven callback to persist from edit time to run time without the need for additional programming and script configuration. iClone Events are useful for a number of things:

  1. Content driven callbacks   
  2. Persistent callbacks
  3. Preconfigured call events

Using iClone Events

To configure a callback in the editor there are a few steps to take:

  1. Make sure your script imports and uses RLPy or related class.
  2. Set global variable(s) for event and event callback.
  3. Register the event and set its corresponding callback
  4. Overwrite the event callback to the received event
  5. Select the function you wish to be called

iClone Event List

There are several Events that iClone provided, listed below:

System Event

You can configure callback functions for the following event triggers:

  • Adding objects to the scene.
  • Removing objects from the scene.
  • Changing the current seletion.
  • Deselecting an object.
  • Performing undos and redos.
  • Playing or stopping the timeline playback.
  • Changing the current timeframe, i.e. dragging the playhead in the timeline.
  • Changing the the timeline by shortening or elongating its duration.

Dialogue Event

If you using RIDialog or RIDockWidget to create your UI, you could receive the events below:

  • Show
  • Hide
  • Close

Timer Event

Using the RLPyTimer will receive the events below:

  • Time Out

Example

The following code demonstrates the use of RPyTimer event to execute an update function every 100 ms.

import RLPy
import time

#-- Initialize the global variable --#
timer_event = None
timer_event_callback = None

#Make a count
count = 0

#-- Overriding RL Timer class --#
class RLPyTimerCallback(RLPy.RPyTimerCallback):
    def __init__(self):
        RLPy.RPyTimerCallback.__init__(self)
	
    #-- Overriding Timeout --#
    def Timeout(self):
        global count
        global timer_event
        global timer_event_callback
        #-- When count more than 10, then Stop the Timer event --#
        if (count < 10):
            count +=1
            #-- Print current in the Console Log panel --#
            print (time.time())
        else:
            #-- Stop the Timer event --#
            timer_event.Stop()
            #-- Unregister Timer Event to save the resource --#
            timer_event.UnregisterPyTimerCallback(timer_event_callback) 


def run_script():
    global timer_event
    global timer_event_callback
	
    #-- Initialize the Timer --#
    timer_event = RLPy.RPyTimer()
    timer_event.SetInterval(100)
	
    #-- Initialize the Timer Callback --#
    timer_event_callback = RLPyTimerCallback()
	
    #-- Register Timer Event to Timer Callback --#
    timer_event.RegisterPyTimerCallback(timer_event_callback) 
    
    #-- Start Timer --#
    timer_event.Start()