IC Python API:iClone Events System
From Reallusion Wiki!
Revision as of 23:42, 6 January 2019 by Chuck (RL) (Talk | contribs) (Created page with "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 Eve...")
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:
- Content driven callbacks
- Persistent callbacks
- Preconfigured call events
Contents
Using iClone Events
To configure a callback in the editor there are a few steps to take:
- Make sure your script imports and uses RLPy or related class.
- Set global variable(s) for event and event callback.
- Register the event and set its corresponding callback
- Overwrite the event callback to the received event
- Select the function you wish to be called
iClone Events 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 Code
The following code demonstrates the use of RPyTimer event to execute an update function every 100 ms.
Code: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()