XSIApplication.InstallAddon

Description

Installs an .xsiaddon file in Softimage. An add-on file is a set of customized items (like layout, toolbar, preset, etc.) that are packaged in a single file. You can package, install and uninstall an add-on through the Softimage object model.

Scripting Syntax

XSIApplication.InstallAddon( FileName, [InstallDir], [NoUI] );

Parameters

Parameter Type Description
FileName String File path of the add-on file to install.
InstallDir siInstallationPath Destination directory, where the add-on is installed.

siUserAddonPath and siWorkgroupAddonPath are the recommended values. If siUnknownPath is specified then the add-on will be installed at the default location specified inside the add-on file.

Note: In the case of multiple workgroups, this method always installs to the first workgroup in the list.

Default Value: siUnknownPath

NoUI Boolean Use this optional parameter to avoid displaying the warning message boxes that are shown during the installation of certain addons. This is automatically set when running Softimage in batch mode.

Default Value: false

Examples

JScript Example

//
// This example demonstrates how to install an add-on package.
//
// Get the first available workgroup as the add-on destination 
var sPath = Application.InstallationPath( siWorkgroupPath );
if ( !sPath ) {
        // If the workgroup doesn't already exist, then add it
        var tmppath = XSIUtils.BuildPath( Application.InstallationPath(siUserPath), "TempWorkgrp" );
        var fso = new ActiveXObject( "Scripting.FileSystemObject" );
        if ( !fso.FolderExists(tmppath) ) { fso.CreateFolder(tmppath); }
        Application.AddWorkgroup( tmppath );
        sPath = Application.InstallationPath( siWorkgroupPath );
}
var sHTMLName = makeHTMLPage();
// Create the add-on package object
var oAddOn = Application.CreateAddon();
// Add the HTML page to the add-on package
oAddOn.AddOtherItem( sHTMLName );
// Save the package in the Addons directory
sPath = XSIUtils.BuildPath( sPath, "Addons" );
XSIUtils.EnsureFolderExists( sPath );
var sAddOnFileName = XSIUtils.BuildPath( sPath, "myHelpPkg.xsiaddon" );
oAddOn.Save( sAddOnFileName );
Application.LogMessage( "Created add-on file: " + sAddOnFileName );
// Install the add-on package containing the HTML page
Application.InstallAddOn( sAddOnFileName, siWorkgroupAddonPath );
// Comment out the following line if you want to see the add-on file 
// (you will have to uninstall the add-on manually):
Application.UnInstallAddon( sAddOnFileName );
// **********************************
// This function just provide the means to remove the details of 
// creating the HTML page. 
function makeHTMLPage()
{
        // Build the filename & path
        var sUserPath = Application.InstallationPath( siUserPath );
        var sHelpFileName = XSIUtils.BuildPath( sUserPath, "Data", "HelpMe.html" );
        // Create a standard hello world script file
        var fso = new ActiveXObject( "Scripting.FileSystemObject" );
        var fHWFile = fso.CreateTextFile( sHelpFileName );
        fHWFile.WriteLine( "<html>" );
        fHWFile.WriteLine( "<head>" );
        fHWFile.WriteLine( "\t<title>Help Page for Testing Add-ons</title>" );
        fHWFile.WriteLine( "</head>" );
        fHWFile.WriteLine( "<body>" );
        fHWFile.WriteLine( "\n<p>Help! I'm trapped inside this HTML code!</p>" );
        fHWFile.WriteLine( "</body>" );
        fHWFile.WriteLine( "</html>" );
        fHWFile.Close();
        // Return the name of the new html page
        return sHelpFileName;
}

See Also

XSIApplication.UnInstallAddon XSIApplication.CreateAddon PackageAddon