What specifically must your scene-specific script do? Generally speaking, you should write your events to be very generic. The event will always fire, but will only do meaningful work if certain data or criteria is met in the scene. The advantage to this method over the scriptNode technique is users can't mess with script events easily ensuring a certain level of stability within your production.
We have a few event scripts along this fashion. One has the responsibility of scanning the scene for customparamsets and converting them to the equivalent self installing custom property while preserving parameter values and connections to sources such as expressions or FCurves. If there are no customparamsets in the scene, the event doesn't do any work. Another example is our face animation system. Our faces are built like components of a Mr. Potato Head doll. Each face asset is a model which plugs into the body and has a self installing custom property applied to its model root for identification. If the scene load event sees this scenario, it knows to clear out the animation mixer of the face and rebuild it from data stored in a database table. If there are no faces in the scene, then the event does nothing. Basically I structured it so there is one event of each type installed, and the event's job is to determine if work needs to be done at the time it's called. If so, a command is called by the event which performs the actual work. A command is called for two reasons: 1) keeps event code simple and generic 2) a command is logged as a single edit in the undo history and is undoable with a single undo operation, code written directly in the event script is not. If you insist on going the scriptNode route, you can get a text or annotation property and stick it at the scene root injecting it with your script code to setup a bootstrap environment. Your event script would look for these properties, and if found, execute the code contained within the property. It's easy to set up, but it's also very easy to cause all sorts of problems as users can interact with this data and mishandle or abuse it to create really big headaches for you. Some of which may not be solvable. Another problem is when the script code needs updating. You'll have to save a new version of the scene to induce the change. If the user needs to roll back the scene for a different reason, well, you're code is now out of sync and may possibly introduce a bug you've just fixed. Since the user doesn't know about the problem, he/she won't know not to roll back or won't be able to recover your bug fix because it was lost when the scene was rolled back to a previous verison. Using the script event system, your code is abstracted away from the scene and not prone to this type of problem. Matt -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Yi Liang Siew Sent: Tuesday, July 29, 2014 7:32 AM To: [email protected] Subject: Making custom events scene-specific? Hi all! Lately I've been trying to port a small little PyQT tool I made over to XSI, but I'm running into a little problem: I've been trying to figure out a way I could get a python script to fire off upon loading of a specific scene (Ideally this would be the equivalent of the scriptNode in Maya). I guess I could make a plugin that looks specifically for a custom event of the scene load and match it by name, then store that with my project, but I'm wondering if there is a more elegant solution already for this that I've overlooked. Thanks!

