XSIApplication.LoadPlugin

説明

自己インストール可能なプラグインファイルをロードします。拡張子が.dll、.so、.vbs、.pys、.ps、.js のファイルが有効とみなされます。このメソッドは、新しくロードされたプラグインを表す Plugin オブジェクトを戻します。

プラグインがすでにロードされている場合は、既存のプラグインを戻します。

C#構文

Plugin XSIApplication.LoadPlugin( String in_pluginName );

スクリプト構文

oReturn = XSIApplication.LoadPlugin( Path );

戻り値

Plugin

パラメータ

パラメータ タイプ 説明
Path String ロードするプラグインのフルファイルパス

JScript の例

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

//	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 ExLoadPluginDemo(filename)

{

	// manually load the plugin

	var oPlugin = Application.LoadPlugin( filename );

	// Display the plug-in information

	Application.LogMessage( "Name: " 		+ oPlugin.Name );

	Application.LogMessage( "Author: "		+ oPlugin.Author );

	Application.LogMessage( "Major: "		+ oPlugin.Major );

	Application.LogMessage( "Minor: "		+ oPlugin.Minor );

	Application.LogMessage( "Language: "	+ oPlugin.Language );

	Application.LogMessage( "Filename: "	+ oPlugin.Filename );

	Application.LogMessage( "URL: "			+ oPlugin.URL );

	Application.LogMessage( "Email: "		+ oPlugin.Email );

	Application.LogMessage( "Help: "		+ oPlugin.Help );

	Application.LogMessage( "OriginPath: "	+ oPlugin.OriginPath );

	Application.LogMessage( "Categories: "	+ oPlugin.Categories.toArray().join(",") );

	Application.LogMessage( "Loaded: "		+ oPlugin.Loaded );

	// The above script logs the following results:

	//INFO : Name: XSIApplication.LoadPlugin Example

	//INFO : Author: Softimage Co.

	//INFO : Major: 1

	//INFO : Minor: 0

	//INFO : Language: JScript

	//INFO : Filename: [userpath]\Addons\XSISDKDocExamples\Application\Plugins\ExXSIApplicationLoadPlugin.js

	//INFO : URL: www.softimage.com

	//INFO : Email: xsi@softimage.com

	//INFO : Help: [factorypath]\Addons\XSISDKDocExamples\Application\Plugins\doc\ExXSIApplicationLoadPlugin.html

	//INFO : OriginPath: [userpath]\Addons\XSISDKDocExamples\Application\Plugins\

	//INFO : Categories: Demo

	//INFO : Loaded: True

}

function  XSILoadPlugin( in_reg )

{

	in_reg.Name = "XSIApplication.LoadPlugin 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 = "Demo"; 

	// generate help files

	GeneratePluginHelpFile(in_reg);

	return true;

} 

function GeneratePluginHelpFile( in_reg )

{

	var fso = XSIFactory.CreateActiveXObject("Scripting.FileSystemObject");

	var pluginfolder = fso.GetParentFolderName( in_reg.filename );

	var helpfolder = fso.BuildPath( pluginfolder, "Doc" );

	if ( ! fso.FolderExists(helpfolder ) )

	{

		fso.CreateFolder(helpfolder);	

	}

	var helpfilename = fso.GetBaseName(in_reg.filename);

	var helpfile = fso.BuildPath( helpfolder, helpfilename + ".html" );

	var file = fso.CreateTextFile ( helpfile );

	file .WriteLine( "<html>" );

	file .WriteLine( "<head>" );

	file .WriteLine( "\t<title>" + in_reg.name + "Help</title>" );

	file .WriteLine( "</head>");

	file .WriteLine( "<body>");

	file .WriteLine( "\t<p>description of "+in_reg.name+" plugin</p>" );

	file .WriteLine( "</body>" );

	file .WriteLine( "</html>" );

	file.close();

}

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

// Code to bootstrap example into system

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

function ExampleSourceCode()

{

	return "// XSISDK Doc Example\n" +

		GeneratePluginHelpFile.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 		= "ExXSIApplicationLoadPlugin";

	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();

	}

	ExLoadPluginDemo( filename );

}

関連項目

XSIApplication.UnloadPlugin XSIApplication.Plugins