Difference between revisions of "IC Python API:RLPy REventHandler"
Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Detailed Description== This class is used to register callbacks for system events. <syntaxhighlight lang="Python">...") |
Chuck (RL) (Talk | contribs) m |
||
Line 1: | Line 1: | ||
{{TOC}} | {{TOC}} | ||
{{Parent|IC_Python_API:RL_Python_Modules|Modules}} | {{Parent|IC_Python_API:RL_Python_Modules|Modules}} | ||
− | == | + | {{last_modified}} |
− | + | ||
− | <syntaxhighlight lang=" | + | == Description == |
+ | |||
+ | Inside iClone, events are responsible for communicating various types of status changes. For recieving different types of events, one would need to inherit from the [[IC_Python_API:RLPy_REventCallback|REventCallback]] base class, and use [[#RegisterCallback ( pCallback )|RegisterCallback]] to register it. Then, one is able to execute relevant commands for the corresponding events, i.e. refreshing user interfaces, etc. | ||
+ | |||
+ | See Also: [[IC_Python_API:RLPy_REventCallback|REventCallback]] | ||
+ | |||
+ | == Member Functions == | ||
+ | |||
+ | === RegisterCallback ( pCallback ) === | ||
+ | |||
+ | Register an event callback and return an id which can be used when UnregisterCallback is called. | ||
+ | |||
+ | See Also: [[#UnregisterCallback ( uId )|UnregisterCallback]] | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :'''pCallback''' [IN] The callback event - [[IC_Python_API:RLPy_REventCallback|REventCallback]] | ||
+ | |||
+ | ==== Returns ==== | ||
+ | :The newly registered callback id - integer | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
class MyEventCallback(RLPy.REventCallback): | class MyEventCallback(RLPy.REventCallback): | ||
− | + | def __init__(self): | |
− | + | RLPy.REventCallback.__init__(self) | |
− | + | def OnObjectSelectionChanged(self): | |
− | + | print("OnObjectSelectionChanged") | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
# register event | # register event | ||
event_callback = MyEventCallback() | event_callback = MyEventCallback() | ||
id = RLPy.REventHandler.RegisterCallback(event_callback) | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | + | === UnregisterCallback ( uId ) === | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | === | + | |
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | + | ||
− | ''' | + | Unregister a callback event by id. When successful, the EventCallback will be removed and the system will no longer receive the event. If the id can not be found, then return '''RLPy.RStatus.Failure'''. |
− | + | ||
− | + | ||
− | + | ||
− | + | See Also: [[#UnregisterCallbacks ( kIds )|UnregisterCallbacks]] | |
− | ''' | + | ==== Parameters ==== |
− | + | :'''uId''' [IN] Id - integer | |
− | + | ||
− | === | + | ==== Returns ==== |
− | <syntaxhighlight lang=" | + | :Success - RLPy.RStatus.Success |
− | RLPy.REventHandler. | + | :Failure - RLPy.RStatus.Failure |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class MyEventCallback(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnObjectSelectionChanged(self): | ||
+ | print("OnObjectSelectionChanged") | ||
+ | |||
+ | event_callback = MyEventCallback() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | # do something | ||
+ | status = RLPy.REventHandler.UnregisterCallback(id) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === UnregisterCallbacks ( kIds ) === | |
− | + | ||
− | === | + | |
− | + | ||
− | '''RLPy.RStatus. | + | Unregister several callback events at once. If an id in the list can not be found, then return '''RLPy.RStatus.Failure'''. |
− | ''' | + | See Also: [[#UnregisterCallback ( uId )|UnregisterCallback]] |
− | + | ||
− | + | ==== Parameters ==== | |
− | === | + | :'''kIds''' [IN] Event callback ids - List |
− | <syntaxhighlight lang=" | + | |
− | RLPy.REventHandler. | + | ==== Return ==== |
+ | :Success - RLPy.RStatus.Success | ||
+ | :Failure - RLPy.RStatus.Failure | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class MyEventCallback(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnObjectSelectionChanged(self): | ||
+ | print("OnObjectSelectionChanged") | ||
+ | |||
+ | event_callback = MyEventCallback() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | # do something | ||
+ | status = RLPy.REventHandler.UnregisterCallbacks([id]) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− |
Latest revision as of 01:39, 29 April 2020
- Main article: Modules.
- Last modified: 04/29/2020
Description
Inside iClone, events are responsible for communicating various types of status changes. For recieving different types of events, one would need to inherit from the REventCallback base class, and use RegisterCallback to register it. Then, one is able to execute relevant commands for the corresponding events, i.e. refreshing user interfaces, etc.
See Also: REventCallback
Member Functions
RegisterCallback ( pCallback )
Register an event callback and return an id which can be used when UnregisterCallback is called.
See Also: UnregisterCallback
Parameters
- pCallback [IN] The callback event - REventCallback
Returns
- The newly registered callback id - integer
1 class MyEventCallback(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectSelectionChanged(self):
5 print("OnObjectSelectionChanged")
6
7 # register event
8 event_callback = MyEventCallback()
9 id = RLPy.REventHandler.RegisterCallback(event_callback)
UnregisterCallback ( uId )
Unregister a callback event by id. When successful, the EventCallback will be removed and the system will no longer receive the event. If the id can not be found, then return RLPy.RStatus.Failure.
See Also: UnregisterCallbacks
Parameters
- uId [IN] Id - integer
Returns
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 class MyEventCallback(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectSelectionChanged(self):
5 print("OnObjectSelectionChanged")
6
7 event_callback = MyEventCallback()
8 id = RLPy.REventHandler.RegisterCallback(event_callback)
9 # do something
10 status = RLPy.REventHandler.UnregisterCallback(id)
UnregisterCallbacks ( kIds )
Unregister several callback events at once. If an id in the list can not be found, then return RLPy.RStatus.Failure.
See Also: UnregisterCallback
Parameters
- kIds [IN] Event callback ids - List
Return
- Success - RLPy.RStatus.Success
- Failure - RLPy.RStatus.Failure
1 class MyEventCallback(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectSelectionChanged(self):
5 print("OnObjectSelectionChanged")
6
7 event_callback = MyEventCallback()
8 id = RLPy.REventHandler.RegisterCallback(event_callback)
9 # do something
10 status = RLPy.REventHandler.UnregisterCallbacks([id])