What is a Self-Installing Plug-in?

 
 
 

A self-installing plug-in is a script file or a compiled .dll/.so that implements a function named XSILoadPlugin.

When Softimage starts, it looks in certain folders, such as Application\Plugins, for plug-ins that implement XSILoadPlugin. When Softimage finds a self-installing plug-in, Softimage loads the plug-in and calls its XSILoadPlugin function.

XSILoadPlugin sets some plug-in properties (such as the name of the plug-in and the location of its help file) and then registers the items that the plug-in implements. Plug-in items can be commands, events, filters, menus, properties, as well as custom displays, viewport modes or callbacks (graphic sequencer).

For example, this XSILoadPlugin registers a command and a menu:

// JScript
function XSILoadPlugin( in_pluginRegistrar )
{
	in_pluginRegistrar.Author = "Command Wizard";
	in_pluginRegistrar.Name = "My Commands";
	
	// Register command
	in_pluginRegistrar.RegisterCommand("MyCommand","MyCommand");
	
	// Register a custom menu
	in_pluginRegistrar.RegisterMenu( siMenuMainHelpID, "MyHelp_Menu", false, false );
	
	in_pluginRegistrar.RegisterMenu(siMenuTbGetPropertyID,"MyProperty_Menu",false,false);
	
	return true;
}

For each plug-in item registered in XSILoadPlugin, a self-installing plug-in also implements a number of callback functions. For example, if a plug-in registers a command named "MyCommand", then the plug-in will also provide an Execute callback, and possibly an Init callback too, for the command.

// JScript
// Init and Execute callbacks for the custom command named "MyCommand"
function MyCommand_Init() {
	// Add arguments to the command
}

function MyCommand_Execute() {
	// Implement the command
}

A self-installing plug-in can also implement an XSIUnloadPlugin function. Softimage calls XSIUnloadPlugin whenever the plug-in is unloaded (for example, from the Plug-in Manager or when Softimage exits). XSIUnloadPlugin allows you to clean up any resources allocated by XSILoadPlugin.

Creative Commons License Except where otherwise noted, this work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported License