Difference between revisions of "IC Python API:RLPy REventCallback"
Chuck (RL) (Talk | contribs) m |
Chuck (RL) (Talk | contribs) m |
||
Line 7: | Line 7: | ||
This class provides a way to monitor iClone events and register callbacks for system events. Once an instance is created, iClone trigger events can be recieved, i.e. playback status, file read status, object creation and deletion status, etc. | This class provides a way to monitor iClone events and register callbacks for system events. Once an instance is created, iClone trigger events can be recieved, i.e. playback status, file read status, object creation and deletion status, etc. | ||
− | [[IC_Python_API:RLPy_REventCallback|REventCallback]] can not be created as a local variable, otherwise the application will crash. Errors in the callback function can also cause the application to crash without | + | [[IC_Python_API:RLPy_REventCallback|REventCallback]] can not be created as a local variable, otherwise the application will crash. Errors in the callback function can also cause the application to crash without warning, therefore, one should consider using Python's '''try except''' for fool-proof implementation. |
=== Inheritance === | === Inheritance === |
Latest revision as of 23:29, 29 April 2020
Contents
- 1 Description
- 2 Member Functions
- 2.1 OnTimerUpdated ( self, fTime )
- 2.2 OnCurrentTimeChanged ( self, fTime )
- 2.3 OnBeforeLoadFile ( self,nFileType )
- 2.4 OnFileLoaded ( self, nFileType )
- 2.5 OnAfterFileLoaded ( self, nFileType )
- 2.6 OnProjectDataChanged ( self, nProjectDataType )
- 2.7 OnBeforeSaveFile ( self, nFileTypep, strProjectName )
- 2.8 OnFileSaved ( self, nFileType, strProjectName )
- 2.9 OnObjectSelectionChanged ( self )
- 2.10 OnObjectDataChanged ( self )
- 2.11 OnObjectAdded ( self )
- 2.12 OnObjectDeleted ( self )
- 2.13 OnDialogModeChanged ( self, nDialogMode )
- 2.14 OnUndoRedoDone ( self )
- 2.15 OnPlayed ( self )
- 2.16 OnStopped ( self )
- 2.17 OnObjectDataChangedWithType ( self, nDataType )
- 2.18 OnHierarchyChanged ( self )
- Main article: Modules.
- Last modified: 04/29/2020
Description
This class provides a way to monitor iClone events and register callbacks for system events. Once an instance is created, iClone trigger events can be recieved, i.e. playback status, file read status, object creation and deletion status, etc.
REventCallback can not be created as a local variable, otherwise the application will crash. Errors in the callback function can also cause the application to crash without warning, therefore, one should consider using Python's try except for fool-proof implementation.
Inheritance
RCallback> REventCallback
Examples
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnTimerUpdated (self, fTime):
5 print('Updated time:' + str(fTime))
6 def OnCurrentTimeChanged (self, fTime):
7 print('Current time:' + str(fTime))
8 def OnBeforeLoadFile(self, nFileType):
9 print('File type:' + str(nFileType))
10 def OnFileLoaded(self, nFileType):
11 print('File type:' + str(nFileType))
12 def OnAfterFileLoaded(self, nFileType):
13 print('File type:' + str(nFileType))
14 def OnProjectDataChanged(self, nProjectDataType):
15 print('Project Data type:' + str(nProjectDataType))
16 def OnBeforeSaveFile(self, nFileType, pProjectName):
17 print('File type:' + str(nFileType) + ', Project Data type:' + str(nProjectDataType))
18 def OnFileSaved(self, nFileType, pProjectName):
19 print('File type:' + str(nFileType) + ', Project Data type:' + str(nProjectDataType))
20 def OnObjectSelectionChanged(self):
21 print('Object Selection Changed')
22 def OnObjectDataChanged(self):
23 print('Object Data Changed')
24 def OnObjectAdded(self):
25 print('Object Added')
26 def OnObjectDeleted(self):
27 print('Object Deleted')
28 def OnDialogModeChanged(self, nDialogMode):
29 print('Dialog Mode Changed ~ ' + 'Dialog Mode:' + str(nDialogMode))
30 def OnPickedModeChanged(self, nPickMode, nPreviousPickMode):
31 print('Picked Mode Changed ~ ' + ' Pick Mode:' + str(nPickMode) + ', Previous Pick Mode:' + str(nPreviousPickMode) )
32 def OnUndoRedoDone(self):
33 print('Undo Redo Done')
34 def OnPlayed(self):
35 print('Play')
36 def OnStopped(self):
37 print('Stop')
38
39 # register event
40 event_callback = None
41 def run_script():
42 # register event
43 global event_callback
44 event_callback = REventCallbackSampleCode()
45 id = RLPy.REventHandler.RegisterCallback(event_callback)
Member Functions
OnTimerUpdated ( self, fTime )
Trigger events while the iClone timeline plays back and return the current time during playback.
Parameters
- fTime [IN] current time (ms) - float
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnTimerUpdated (self, fTime):
5 print('Updated time:' + str(fTime))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnCurrentTimeChanged ( self, fTime )
Trigger an event everytime a change has been applied to the iClone timeline and return the current time. For example, updates are triggered when the timeline is stopped and while scrubbing the timeline, but playing the timeline does not.
Parameters
- fTime [IN] current time - float
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnCurrentTimeChanged (self, fTime):
5 print('Current time:' + str(fTime))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnBeforeLoadFile ( self,nFileType )
Trigger an event before an object is read from file and return the object's type.
Parameters
- nFileType [IN] file type - integer
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnBeforeLoadFile(self, nFileType):
5 print('File type:' + str(nFileType))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnFileLoaded ( self, nFileType )
Trigger an event when an object is read from file and return the object's type.
Parameters
- nFileType [IN] file type - integer
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnFileLoaded(self, nFileType):
5 print('File type:' + str(nFileType))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnAfterFileLoaded ( self, nFileType )
Trigger an event after iClone has finished reading an object from file and return the object's type.
Parameters
- nFileType [IN] file type - integer
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnAfterFileLoaded(self, nFileType):
5 print('File type:' + str(nFileType))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnProjectDataChanged ( self, nProjectDataType )
Trigger an event when the iClone project's settings change and return the settings type.
Parameters
- nProjectDataType [IN] project data type - integer
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnProjectDataChanged(self, nProjectDataType):
5 print('Project Data type:' + str(nProjectDataType))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnBeforeSaveFile ( self, nFileTypep, strProjectName )
Trigger an event right before iClone saves a file and return the file path.
Parameters
- nFileType [IN] file type - integer
- strProjectName [IN] project name - string
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnBeforeSaveFile(self, nFileType, strProjectName):
5 print('File type:' + str(nFileType) + ', Project Name:' + str(pProjectName))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnFileSaved ( self, nFileType, strProjectName )
Trigger an event when iClone has succesfully saved a file and return the file path.
Parameters
- nFileType [IN] file type - integer
- strProjectName [IN] project name - string
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnFileSaved(self, nFileType, strProjectName):
5 print('File type:' + str(nFileType) + ', Project Name:' + str(pProjectName))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnObjectSelectionChanged ( self )
Trigger an event when an iClone object is selection.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectSelectionChanged(self):
5 print('Object Selection Changed')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnObjectDataChanged ( self )
Trigger an event when an iClone object data has changed (ObjectChangedDataType).
Enum.ObjectChangedDataType
Enum | Code | Enum | Code | Enum | Code |
---|---|---|---|---|---|
None | 0 | Transform | 1 | Attribute | 2 |
Physics | 4 | Material | 8 | Substance | 16 |
NodeType | 32 | Replace | 64 | Reach | 128 |
Name | 256 | ShapingMorph | 512 | ReplaceAvatar | 1024 |
EditMeshDone | 2048 | CustomMorphWeightChange | 4096 | CustomMorph | 8192 |
PopcornFx | 16384 | SetMainMesh | 32768 | MotionOffset | 65536 |
Motion | 131072 | MeshSmoothSetting | 262144 | CreateLodData | 524288 |
Appearance | 1048576 | SkinSubstance | 2097152 | Texture | 4194304 |
ShaderType | 8388608 | Wrinkle | 16777216 | MaterialTexture | 4194312 |
MaterialAll | 12582920 |
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectDataChanged(self):
5 print('Object Data Changed')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnObjectAdded ( self )
Trigger an event when an iClone object is added to the scene. Currently triggers on the creation of Lights, Cameras, Paths, and duplication of any type of object.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectAdded(self):
5 print('Object Added')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnObjectDeleted ( self )
Trigger an event when an iClone object is deleted.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectDeleted(self):
5 print('Object Deleted')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnDialogModeChanged ( self, nDialogMode )
Trigger an event when an iClone window related function is called and return the window's dialog mode (DialogModeType).
Enum.DialogMode
Enum | Code | Enum | Code | Enum | Code |
---|---|---|---|---|---|
DM_None | 0 | DM_PivotEdit | 1 | DM_DirectPuppet | 2 |
DM_MotionPuppet | 3 | DM_DevicePuppet | 4 | DM_PropPuppet | 5 |
DM_MographEdit | 6 | DM_AvatarProport | 7 | DM_Duplicate | 8 |
DM_IkEditing | 9 | DM_ReachTarget | 10 | DM_BoneSetting | 11 |
DM_QuickLight | 12 | DM_FacePuppet | 13 | DM_FaceKey | 14 |
DM_FacialFeature | 15 | DM_FacialDeform | 16 | DM_FacialMocap | 17 |
DM_ClipMotionPuppet | 18 | DM_PhysicsCenterOfMass | 19 | DM_PhysicsCollisionShape | 20 |
DM_CreateFace | 21 | DM_TTS | 22 | DM_GrassEditing | 23 |
DM_TreeEditing | 24 | DM_PhysicsMaterial | 25 | DM_ClothFitting | 26 |
DM_VisemeSmooth | 27 | DM_CCSubstanceHighPerformance | 28 | DM_NoitomMocapPuppet | 29 |
DM_CreateSlider | 30 | DM_FloorContact | 31 | DM_EditFace | 32 |
DM_EditVertex | 33 | DM_EditElement | 34 | DM_IblEditting | 35 |
DM_MorphAnimation | 36 | DM_EditSkinWeightByVertex | 37 | DM_EditSkinWeightByBrush | 38 |
DM_EditSkinWeightRotateBone | 39 | DM_EditSkinWeightSelectBone | 40 | DM_AdjustTPose | 41 |
DM_FkEditing | 42 | DM_EditPartialConformByVertex | 43 | DM_EditPartialConformByElement | 44 |
DM_EditPartialConformByBrush | 45 | DM_EditNormal | 46 | DM_OptimizeMesh_All | 47 |
DM_OptimizeMesh_Select | 48 | DM_OptimizeMesh_Element | 49 | DM_EditHighHeel | 50 |
DM_EditMeshByBrush | 51 | DM_ConvertToAccessory | 52 | DM_SkinWeightTemplate | 53 |
DM_SelectGameBaseUV | 54 | DM_ContentHideMesh | 55 | DM_ContentHideBodyMeshByFace | 56 |
DM_ContentHideBodyMeshByBrush | 57 | DM_PaintMaskByBrush | 58 | DM_SkinSubstance | 59 |
DM_CC1Substance | 60 | DM_FacialCalibration | 61 | DM_PluginCustomMode | 9527 |
DM_OpenPluginDialog_Begin | 99999 |
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnDialogModeChanged(self, nDialogMode):
5 print('Dialog Mode Changed ~ ' + 'Dialog Mode:' + str(nDialogMode))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
Parameters
- nDialogMode [IN] dialog mode - integer
OnUndoRedoDone ( self )
Trigger an event when an iClone undo or redo action is executed.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnUndoRedoDone(self):
5 print('Undo Redo Done')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnPlayed ( self )
Trigger an event when the iClone timeline begins playing.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnPlayed(self):
5 print('Play')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnStopped ( self )
Trigger an event when the iClone timeline has stopped playing, also works with pausing.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnStopped(self):
5 print('Stop')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnObjectDataChangedWithType ( self, nDataType )
Trigger an event when receiving data updates on iClone objects and retrieve the object type.
Parameters
- nDataType [OUT] ObjectChangedDataType
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnObjectDataChangedWithType(self, nDataType):
5 print('Object Data Changed:' + str(nDataType))
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)
OnHierarchyChanged ( self )
Trigger an event when receiving updates to the heirarchy data structure. Trigger actions include Attach, Detach, ConvertToTerrain, ConvertTerrainToProp, ReachEffector, MergeSubProps.
1 class REventCallbackSampleCode(RLPy.REventCallback):
2 def __init__(self):
3 RLPy.REventCallback.__init__(self)
4 def OnHierarchyChanged(self):
5 print('Hierarchy Changed')
6
7 event_callback = None
8 def run_script():
9 global event_callback
10 event_callback = REventCallbackSampleCode()
11 id = RLPy.REventHandler.RegisterCallback(event_callback)