Profile Picture

Python Class: iClone Events

Posted By jlittle 5 Years Ago
Rated 5 stars based on 1 vote.
Author
Message
jlittle
jlittle
Posted 5 Years Ago
View Quick Profile
Distinguished Member

Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)Distinguished Member (6.7K reputation)

Group: Forum Members
Last Active: Yesterday
Posts: 1.9K, Visits: 17.1K
I put together a simple class that makes it easier to use the iClone system events.
I created this to help make my scripts simpler and cleaner.

Basically all you have to do is:
  • import the class
  • create the object
  • assign your event handler procedures
  • delete the event handler object on script termination.
All the registration and un-registration of the event handler is handled in the class.

Example:
# import MyiCloneEvents class from the file iConeEvents.py
from iCloneEvents import MyiCloneEvents

#---------------------------------------

# create the RL events handler object
iCloneEvents = MyiCloneEvents()

# set up my script event handlers for the iClone events desired
iCloneEvents.setOnBeforeLoadFile(onEvent_BeforeLoadFile)
iCloneEvents.setOnFileLoaded(onEvent_FileLoaded)
iCloneEvents.setOnAfterFileLoaded(onEvent_AfterFileLoaded)
iCloneEvents.setOnBeforeSaveFile(onEvent_BeforeSaveFile)
iCloneEvents.setOnFileSaved(onEvent_FileSaved)
iCloneEvents.setOnObjectSelectionChanged(onEvent_SelectionChanged)
iCloneEvents.setOnObjectAdded(onEvent_ObjectAdded)
iCloneEvents.setOnObjectDeleted(onEvent_ObjectDeleted)
iCloneEvents.setOnPlayed(onEvent_Played)

#---------------------------------------

# on script termination delete the events handler
del iCloneEvents # Note: the event handler object unregisters on deletion



I've included a script (iCloneEventsTest.py) to show how to use it.

The important thing to remember is to delete the object when the script terminates.
This will un-register the event handler from the RL system. If the event handler is not not un-registered then system events will still try to call the event handler which can/will cause iClone to crash.

How your script terminates depends upon your script. The example I provided uses a blank dialog window that when closed uses the "finished "signal to delete the object.

Jeff



Get my Plugin Manager and TaskNotes plugins for iClone.
Check out EZColors and Other products for CTA/CA. EZColors: the easy way to change Render Styled (RS) colors!
See my CTA Tutorials on the YouTube channel CTAStepByStep

Attachments
iCloneEvents.zip (143 views, 2.00 KB)



Reading This Topic