Events (XSISDK)

Softimage supports callbacks which are called when certain "Events" happen in the application, for example when a scene file is opened, the program exits, or a frame is rendered. Be sure to read the documentation: Custom Events (http://softimage.wiki.softimage.com/sdkdocs/cus_events.htm)

Table of contents

Self-Installing Events

Starting with XSI v5.0 Events are now supported as a type of Self-Installed Plugin Item. So XSIApplication.Advise is not the recommended way to register an event. A Wizard has been provided to make it easier to write Events, including C++ API events.

Where are Events Persisted

Information about persisted, non-self-installing events is stored in this file: <UserLocation>\Data\xsicustom.data The file is binary so its contents can not be adjusted. This file also stores the mute state of self-installed events.

Muting a Self-installed Event

Some events are designed to be active all the time. Other events only need to be active during a certain operation, for example while a certain tool is active. Self-installed events are active as soon as the self-installed plug-in is loaded, so the first type of event is automatically supported. However it is also easy to support the second type of event.

One workflow is to register the event but immediately Mute it, using the EventInfo.Mute property. It will be "un-muted", using the same API, at such a time as the event is actually needed. Any code can mute a registered event at any time.

Another workflow is to store the event in a self-installed plugin that is not in the normal search directly. In that case the entire plugin is only loaded when the event is actually needed, then unloaded again, using XSIApplication.LoadPlugin and XSIApplication.UnloadPlugin. This API requires an absolute path to the plugin, but this can be determined programmatically based on a relative path, see Avoiding Absolute Paths. Note: If an event attempts to unload its own plug-in during the execution of an event it may cause Softimage to crash.

A final workflow is to develop your own muting system, so that the event is always active, but when it is fired it checks to see if certain internal conditions are suitable for it to actually do something. So when the event is not needed it gets called but does nothing.

Note: Starting with XSI v5, the EventInfo object is available directly in the C++ API. Previously it was necessary to use the CComAPIHandler.

Example Uses of Events

  • Implement basic interactive tools, via the keydown and keyup events.
  • Integrate with a revision control system, e.g. saving backups of scenes each time they are saved
  • Implementing a custom Auto-Save behavior (when using the new XSI v5.1 timer event)
  • Automatically switch workgroups according to the project. See Storing Plug-ins Inside an XSI Project

Object Events

Softimage does not support events associated with individual objects, but the Custom Display Host (XSISDK) is sometimes used as a way to get notifications.

OnBeginSceneSave

Image:Lightbulb.png
Starting with XSI v5.1 siOnBeginSceneSave2 should be used instead of siOnBeginSceneSave. It is indentical but the callback receives the scene filename.


OnDragAndDrop

A DragAndDrop event is really two different actions: a Drag action and a Drop action. The DragAndDropAction context attribute tells you which action the user is performing.

During the Drag action, you check the drag source and determine whether or not you support that source type. If you support the drag source, then you set the DragSourceSupported attribute to true. This allows the user to drop the source, which generates a DropAction event.

If a user drags multiple files, the DragAndDrop events are triggered for each file.

# DragAndDrop callback for importing FBX
def OnDragAndDropFBX_OnEvent( in_ctxt ):

	DnDAction = in_ctxt.GetAttribute("DragAndDropAction")
	DnDSource = in_ctxt.GetAttribute("DragSource")

	# Check if we support the file type being dragged
	if DnDAction == constants.siSourceDragAction:
		if DnDSource.endswith( ".fbx"):
			in_ctxt.SetAttribute("DragSourceSupported",true);
	else: # DnDAction == constants.siSourceDropAction
		# Import the dropped file
		Application.FBXImportAnimation( true )
		Application.FBXImport( DnDSource, 1 )

	return true

This page was last modified 21:01, 10 Dec 2010.
This page has been accessed 20159 times.

© Copyright 2009 Autodesk Inc. All Rights Reserved. Privacy Policy | Legal Notices and Trademarks | Report Piracy