//--------------------------------------------------------------------
// This example shows how to define and load a plug-in in Softimage
//
// README: Copy and paste the example into the script editor
// and run (F5).
//--------------------------------------------------------------------
function ExUnLoadPluginDemo()
{
// lookup installed plugin
var oPlugin = Application.Plugins( "XSIApplication.UnLoadPlugin Example" );
// manually unload plugin
Application.UnloadPlugin( oPlugin.FileName );
// The above script logs the following results:
//INFO : XSIUnloadPlugin called"
//INFO : Name: XSIApplication.UnLoadPlugin Example"
//INFO : Author: Softimage Co.
//INFO : Major: 1
//INFO : Minor: 0
//INFO : Language: JScript
//INFO : Filename: [userpath]\Addons\XSISDKDocExamples\Application\Plugins\ExXSIApplicationUnLoadPlugin.js
//INFO : URL: www.softimage.com
//INFO : Email: xsi@softimage.com
//INFO : Help:
//INFO : OriginPath: [userpath]\Addons\XSISDKDocExamples\Application\Plugins\
//INFO : Categories: Doc Example
//INFO : Loaded: True
}
function XSILoadPlugin( in_reg )
{
in_reg.Name = "XSIApplication.UnLoadPlugin Example";
in_reg.Author = "Softimage Co.";
in_reg.Major = 1;
in_reg.Minor = 0;
in_reg.URL = "www.softimage.com";
in_reg.Email = "xsi@softimage.com";
in_reg.Categories = "Doc Example";
return true;
}
function XSIUnloadPlugin( in_reg )
{
Application.LogMessage( "XSIUnloadPlugin called" );
Application.LogMessage( "\tName: " + in_reg.Name );
Application.LogMessage( "\tAuthor: " + in_reg.Author);
Application.LogMessage( "\tMajor: " + in_reg.Major);
Application.LogMessage( "\tMinor: " + in_reg.Minor);
Application.LogMessage( "\tLanguage: " + in_reg.Language);
Application.LogMessage( "\tURL: " + in_reg.URL);
Application.LogMessage( "\tEmail: " + in_reg.Email);
Application.LogMessage( "\tHelp: " + in_reg.Help);
Application.LogMessage( "\tOriginPath: " + in_reg.OriginPath);
Application.LogMessage( "\tCategories: " + in_reg.Categories);
}
//--------------------------------------------------------------------
// Code to bootstrap example into system
//--------------------------------------------------------------------
function ExampleSourceCode()
{
return "// XSISDK Doc Example\n" +
XSIUnloadPlugin.toString() + "\n" +
XSILoadPlugin.toString();
}
// if we are running from script editor save code to
// examples addon folder in the user's directory.
if (GetUserPref("ScriptingSessionActive"))
{
var ex_name = "ExXSIApplicationUnLoadPlugin";
var ex_subfolder = "Plugins";
var ex_folder = "XSISDKDocExamples";
var ex_langsuffix = ".js";
CreateAddonDirectories( InstallationPath(siUserPath), ex_folder );
var fso = XSIFactory.CreateActiveXObject("Scripting.FileSystemObject");
var filename = XSIUtils.BuildPath(
InstallationPath(siUserAddonPath),
ex_folder,
"Application",
ex_subfolder,
ex_name+ex_langsuffix );
if (!fso.FileExists(filename))
{
var f = fso.CreateTextFile ( filename );
f.write( ExampleSourceCode() );
f.close();
Application.LoadPlugin(filename);
}
ExUnLoadPluginDemo();
}
|