UnInstallAddon

詳細

Softimage からアドオン ファイルを削除します。 アドオン ファイルは、アドオン パス上(siAddonPath)またはユーザ アドオン パス上(siUserAddonPath)に存在しなければなりません。 元のインストール パスからアドオンを削除しようとするとエラーが発生します。

このコマンドは、メイン メニューの[ファイル] > [アドオン]から[アンインストール]を実行する操作に相当するスクリプトです。

スクリプト構文

UnInstallAddon( FileName );

パラメータ

パラメータ タイプ 説明
FileName 文字列 xsiaddon ファイル

JScript の例

/* ---------------------------------------------------------

	This script demonstrates how to install and uninstall 

	user add-ons and factory add-ons.

--------------------------------------------------------- */

// Get the filename of an available add-on file, and install it, in the user add-on path.

var myAddonFile = createAddonForDemo( siUserPath );

Application.LogMessage( "Installing: " + myAddonFile );

InstallAddon( myAddonFile, siUserAddonPath );

// Now find the installed file.

myAddonFile = XSIUtils.BuildPath( Application.InstallationPath(siUserAddonPath), "DemoAddon.xsiaddon" );

Application.LogMessage( "Uninstalling: " + myAddonFile );

UnInstallAddon( myAddonFile );

killCmdForDemo();		// clean up the command that was loaded from the add-on

// Now re-install it to the AddonPath.

myAddonFile = createAddonForDemo( siFactoryPath );

Application.LogMessage( "Installing: " + myAddonFile );

InstallAddon( myAddonFile, siAddonPath );

// Now uninstall the add-on (again).

myAddonFile = XSIUtils.BuildPath( Application.InstallationPath(siAddonPath), "DemoAddon.xsiaddon" );

Application.LogMessage( "Uninstalling: " + myAddonFile );

UnInstallAddon( myAddonFile );

killCmdForDemo();		// the plug-in is not automatically unloaded when the add-on is uninstalled

//---------------------------------------------------------

// Output from this script:

//INFO : "Installing: <UserPath>\Addons\DemoAddon.xsiaddon"

//INFO : "Uninstalling: <UserPath>\Addons\DemoAddon.xsiaddon"

//INFO : "Installing: <FactoryPath>\Addons\DemoAddon.xsiaddon"

//INFO : "Uninstalling: <FactoryPath>\Addons\InstalledAddons\DemoAddon.xsiaddon"

//---------------------------------------------------------

// 	*** Helper functions *** 

//

// Create an add-on package on the fly

function createAddonForDemo( in_Where )

{

	var l_AddonFile = GetAddonFileLocation( in_Where );

	var l_PluginFile = createCmdForDemo();

	var l_AddonObj = Application.CreateAddon();

	l_AddonObj.AddItem( siPluginAddonItemType, l_PluginFile );

	l_AddonObj.Save( l_AddonFile );

	// Now that it's in the .xsiaddon file, kill the source

	killCmdForDemo(); 

	return l_AddonFile;

}

// Validate the add-on file location

function GetAddonFileLocation( in_Where )

{

	var l_folderLocation = (in_Where == siUserPath) 

		? Application.InstallationPath( siUserAddonPath )

		: Application.InstallationPath( siAddonPath );

	var l_fso = new ActiveXObject( "Scripting.FileSystemObject" );

	// Make sure the Addons folder exists 

	if (! l_fso.FolderExists(l_folderLocation) ) {

		l_fso.CreateFolder( l_folderLocation );

	}

	return XSIUtils.BuildPath( l_folderLocation, "DemoAddon.xsiaddon" );

}

// Create the self-installing command plug-in on disk and load it

function createCmdForDemo()

{

	var l_fileLocation = XSIUtils.BuildPath( Application.InstallationPath(siUserPath), 

		"Application", "Plugins", "JSCmdForAddonsDemoPlugin.js" );

	var l_fso = new ActiveXObject( "Scripting.FileSystemObject" );

	var l_ts = l_fso.CreateTextFile( l_fileLocation );

	l_ts.Write( writeCmdImpl() );

	l_ts.Close();

	Application.LoadPlugin( l_fileLocation );

	return l_fileLocation;

}

// Supply the implementation of the self-installing command plug-in

function writeCmdImpl()

{

	return XSILoadPlugin.toString() + "\n\n" 

		+ JSCmdForAddonsDemo_Init.toString() + "\n\n" 

		+ JSCmdForAddonsDemo_Execute.toString();

}

function XSILoadPlugin( in_reg )

{

	in_reg.Author = "InstallAddonDemo";

	in_reg.Name = "JSCmdForAddonsDemoPlugin";

	in_reg.Major = 1;

	in_reg.Minor = 0;

	in_reg.RegisterCommand("JSCmdForAddonsDemo","JSCmdForAddonsDemo");

	return true;

}

function JSCmdForAddonsDemo_Init( in_ctxt )

{

	var oCmd = in_ctxt.Source;

	oCmd.Description = "'Hello World' command for demonstration";

	oCmd.ReturnValue = false;

	return true;

}

function JSCmdForAddonsDemo_Execute(  )

{

	Application.LogMessage("Hello, World!", siInfo);

	return true;

}

// Remove the self-installing command plug-in (and delete from disk)

function killCmdForDemo()

{

	var p = new Enumerator( Application.Plugins );

	for ( ; !p.atEnd(); p.moveNext() ) {

		var plugin = p.item();

		if ( plugin.Name == "JSCmdForAddonsDemoPlugin" ) {

			Application.UnloadPlugin( plugin.Filename, true );

			break;

		}

	}

}

関連項目

InstallAddon XSIApplication.InstallAddon XSIApplication.UnInstallAddon Addon Plugin