Profile Picture

Python Class: iClone Events

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

Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)Distinguished Member (3.3K reputation)

Group: Forum Members
Last Active: 26 minutes ago
Posts: 1.5K, Visits: 11.5K
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



See my CTA Tutorials on the YouTube channel CTAStepByStep
Check out EZColors for CTA. The easy way to change Render Styled (RS) colors.

Attachments
iCloneEvents.zip (14 views, 2.00 KB)



Reading This Topic