Difference between revisions of "IC Python API:RLPy REventCallback"
Chuck (RL) (Talk | contribs) (Created page with "{{TOC}} {{Parent|IC_Python_API:RL_Python_Modules|Modules}} ==Inheritance== This class inherits public member functions from: *RLPy.RCallback =...") |
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}} |
− | This class | + | |
− | + | == 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. Note: [[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 warnings, therefore one should consider using Python's '''try except''' for fool-proof implementation. | |
− | <syntaxhighlight lang=" | + | |
+ | === Inheritance === | ||
+ | |||
+ | [[IC_Python_API:RLPy_RCallback|RCallback]]> [[IC_Python_API:RLPy_REventCallback|REventCallback]] | ||
+ | |||
+ | === Examples === | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
class REventCallbackSampleCode(RLPy.REventCallback): | class REventCallbackSampleCode(RLPy.REventCallback): | ||
− | + | def __init__(self): | |
− | + | RLPy.REventCallback.__init__(self) | |
+ | def OnTimerUpdated (self, fTime): | ||
+ | print('Updated time:' + str(fTime)) | ||
+ | def OnCurrentTimeChanged (self, fTime): | ||
+ | print('Current time:' + str(fTime)) | ||
+ | def OnBeforeLoadFile(self, nFileType): | ||
+ | print('File type:' + str(nFileType)) | ||
+ | def OnFileLoaded(self, nFileType): | ||
+ | print('File type:' + str(nFileType)) | ||
+ | def OnAfterFileLoaded(self, nFileType): | ||
+ | print('File type:' + str(nFileType)) | ||
+ | def OnProjectDataChanged(self, nProjectDataType): | ||
+ | print('Project Data type:' + str(nProjectDataType)) | ||
+ | def OnBeforeSaveFile(self, nFileType, pProjectName): | ||
+ | print('File type:' + str(nFileType) + ', Project Data type:' + str(nProjectDataType)) | ||
+ | def OnFileSaved(self, nFileType, pProjectName): | ||
+ | print('File type:' + str(nFileType) + ', Project Data type:' + str(nProjectDataType)) | ||
+ | def OnObjectSelectionChanged(self): | ||
+ | print('Object Selection Changed') | ||
+ | def OnObjectDataChanged(self): | ||
+ | print('Object Data Changed') | ||
+ | def OnObjectAdded(self): | ||
+ | print('Object Added') | ||
+ | def OnObjectDeleted(self): | ||
+ | print('Object Deleted') | ||
+ | def OnDialogModeChanged(self, nDialogMode): | ||
+ | print('Dialog Mode Changed ~ ' + 'Dialog Mode:' + str(nDialogMode)) | ||
+ | def OnPickedModeChanged(self, nPickMode, nPreviousPickMode): | ||
+ | print('Picked Mode Changed ~ ' + ' Pick Mode:' + str(nPickMode) + ', Previous Pick Mode:' + str(nPreviousPickMode) ) | ||
+ | def OnUndoRedoDone(self): | ||
+ | print('Undo Redo Done') | ||
+ | def OnPlayed(self): | ||
+ | print('Play') | ||
+ | def OnStopped(self): | ||
+ | print('Stop') | ||
+ | |||
+ | # register event | ||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | # register event | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
− | + | == 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 | |
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | class REventCallbackSampleCode(RLPy.REventCallback): | |
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnTimerUpdated (self, fTime): | ||
+ | print('Updated time:' + str(fTime)) | ||
− | + | event_callback = None | |
− | + | def run_script(): | |
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
− | + | === 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 | |
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | class REventCallbackSampleCode(RLPy.REventCallback): | |
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnCurrentTimeChanged (self, fTime): | ||
+ | print('Current time:' + str(fTime)) | ||
− | + | event_callback = None | |
− | + | def run_script(): | |
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
− | + | === 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 | |
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | class REventCallbackSampleCode(RLPy.REventCallback): | |
− | + | def __init__(self): | |
− | + | RLPy.REventCallback.__init__(self) | |
− | event_callback = REventCallbackSampleCode() | + | def OnBeforeLoadFile(self, nFileType): |
− | id = RLPy.REventHandler.RegisterCallback(event_callback) | + | print('File type:' + str(nFileType)) |
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | == | + | |
− | === | + | === OnFileLoaded ( self, nFileType ) === |
− | <syntaxhighlight lang=" | + | |
− | RLPy.REventCallback. | + | Trigger an event when an object is read from file and return the object's type. |
+ | |||
+ | ===== Parameters ===== | ||
+ | :'''nFileType''' [IN] file type - integer | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnFileLoaded(self, nFileType): | ||
+ | print('File type:' + str(nFileType)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | '''nFileType''' [IN] file type - | + | === OnAfterFileLoaded ( self, nFileType ) === |
− | + | ||
− | + | Trigger an event after iClone has finished reading an object from file and return the object's type. | |
− | + | ||
− | <syntaxhighlight lang=" | + | ===== Parameters ===== |
− | RLPy.REventCallback. | + | :'''nFileType''' [IN] file type - integer |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnAfterFileLoaded(self, nFileType): | ||
+ | print('File type:' + str(nFileType)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | ''' | + | === OnProjectDataChanged ( self, nProjectDataType ) === |
− | + | ||
− | + | Trigger an event when the iClone project's settings change and return the settings type. | |
− | + | ||
− | <syntaxhighlight lang=" | + | ==== Parameters ==== |
− | RLPy.REventCallback. | + | :'''nProjectDataType''' [IN] project data type - integer |
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnProjectDataChanged(self, nProjectDataType): | ||
+ | print('Project Data type:' + str(nProjectDataType)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === OnBeforeSaveFile ( self, nFileTypep, strProjectName ) === | |
− | ''' | + | Trigger an event right before iClone saves a file and return the file path. |
− | + | ||
− | + | ==== Parameters ==== | |
− | + | :'''nFileType''' [IN] file type - integer | |
− | <syntaxhighlight lang=" | + | :'''strProjectName''' [IN] project name - string |
− | RLPy.REventCallback. | + | |
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnBeforeSaveFile(self, nFileType, strProjectName): | ||
+ | print('File type:' + str(nFileType) + ', Project Name:' + str(pProjectName)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | ''' | + | === OnFileSaved ( self, nFileType, strProjectName ) === |
− | + | ||
− | + | Trigger an event when iClone has succesfully saved a file and return the file path. | |
− | + | ||
− | <syntaxhighlight lang=" | + | ==== Parameters ==== |
− | RLPy.REventCallback. | + | :'''nFileType''' [IN] file type - integer |
+ | :'''strProjectName''' [IN] project name - string | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnFileSaved(self, nFileType, strProjectName): | ||
+ | print('File type:' + str(nFileType) + ', Project Name:' + str(pProjectName)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === OnObjectSelectionChanged ( self ) === | |
− | + | ||
− | + | Trigger an event when an iClone object is selection. | |
− | === | + | |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
− | RLPy.REventCallback. | + | class REventCallbackSampleCode(RLPy.REventCallback): |
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnObjectSelectionChanged(self): | ||
+ | print('Object Selection Changed') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === OnObjectDataChanged ( self ) === | |
− | + | ||
− | + | Trigger an event when an iClone object data has changed (ObjectChangedDataType). | |
− | === | + | |
− | <syntaxhighlight lang=" | + | ==== Enum.ObjectChangedDataType ==== |
− | RLPy.REventCallback. | + | |
+ | {| class="wikitable" | ||
+ | |- | ||
+ | !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 | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |} | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnObjectDataChanged(self): | ||
+ | print('Object Data Changed') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === 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. | |
− | + | ||
− | + | <syntaxhighlight lang="python" line='line'> | |
− | + | class REventCallbackSampleCode(RLPy.REventCallback): | |
− | <syntaxhighlight lang=" | + | def __init__(self): |
− | RLPy.REventCallback. | + | RLPy.REventCallback.__init__(self) |
+ | def OnObjectAdded(self): | ||
+ | print('Object Added') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | + | === OnObjectDeleted ( self ) === | |
− | + | ||
− | + | Trigger an event when an iClone object is deleted. | |
− | === | + | |
− | <syntaxhighlight lang=" | + | <syntaxhighlight lang="python" line='line'> |
− | RLPy.REventCallback. | + | class REventCallbackSampleCode(RLPy.REventCallback): |
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnObjectDeleted(self): | ||
+ | print('Object Deleted') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | ''' | + | === OnDialogModeChanged ( self, nDialogMode ) === |
− | </ | + | |
+ | Trigger an event when an iClone window related function is called and return the window's dialog mode (DialogModeType). | ||
+ | |||
+ | ==== Enum.DialogMode ==== | ||
+ | |||
+ | {| class="wikitable" | ||
+ | |- | ||
+ | !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 | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | | | ||
+ | |} | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnDialogModeChanged(self, nDialogMode): | ||
+ | print('Dialog Mode Changed ~ ' + 'Dialog Mode:' + str(nDialogMode)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :'''nDialogMode''' [IN] dialog mode - integer | ||
+ | |||
+ | === OnUndoRedoDone ( self ) === | ||
+ | |||
+ | Trigger an event when an iClone undo or redo action is executed. | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnUndoRedoDone(self): | ||
+ | print('Undo Redo Done') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === OnPlayed ( self ) === | ||
+ | |||
+ | Trigger an event when the iClone timeline begins playing. | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnPlayed(self): | ||
+ | print('Play') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === OnStopped ( self ) === | ||
+ | |||
+ | Trigger an event when the iClone timeline has stopped playing, also works with pausing. | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnStopped(self): | ||
+ | print('Stop') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === OnObjectDataChangedWithType ( self, nDataType ) === | ||
+ | |||
+ | Trigger an event when receiving data updates on iClone objects and retrieve the object type. | ||
+ | |||
+ | ==== Parameters ==== | ||
+ | :'''nDataType''' [OUT] ObjectChangedDataType | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnObjectDataChangedWithType(self, nDataType): | ||
+ | print('Object Data Changed:' + str(nDataType)) | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> | ||
+ | |||
+ | === OnHierarchyChanged ( self ) === | ||
+ | |||
+ | Trigger an event when receiving updates to the heirarchy data structure. Trigger actions include Attach, Detach, ConvertToTerrain, ConvertTerrainToProp, ReachEffector, MergeSubProps. | ||
+ | |||
+ | <syntaxhighlight lang="python" line='line'> | ||
+ | class REventCallbackSampleCode(RLPy.REventCallback): | ||
+ | def __init__(self): | ||
+ | RLPy.REventCallback.__init__(self) | ||
+ | def OnHierarchyChanged(self): | ||
+ | print('Hierarchy Changed') | ||
+ | |||
+ | event_callback = None | ||
+ | def run_script(): | ||
+ | global event_callback | ||
+ | event_callback = REventCallbackSampleCode() | ||
+ | id = RLPy.REventHandler.RegisterCallback(event_callback) | ||
+ | </syntaxhighlight> |
Revision as of 22:34, 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. Note: 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 warnings, 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)