XSIUtils.RegisterSPDL

導入

v4.0

詳細

レジストリに sPDL ファイルをインストールし、オプションで新しいプリセットを作成します。

警告:これはローレベル API です。Softimage のインストールに影響する可能性があるため、使用時には注意が必要です。

このメソッドは、SPDL ファイルに特定の「クラス ID」(CLSID)を関連付けます。Softimage の各オブジェクトには、独自のクラス ID が付きます。たとえば、Phong シェーダには Lambert シェーダとは異なる CLSID が付いています。CustomProperty が作成されるたびに、新しいユニークな CLSID が割り当てられます。ただし、CustomProperty を(カットアンドペーストや SceneItem.AddProperty で)複製した場合は、複製元と同じ CLSID が共有されます(「siObjectIdentifierType」を参照)

すべての SPDL ファイルにはファイルの一番上に参照 GUID があり、これによって、関連付けられている CLSID が識別されます。ただし、Softimage では未登録の SPDL ファイルは SPDL ファイルとして認識されません。Custom Property は必ず SPDL ファイルが必要というわけではありません。SPDL ファイルがない場合はパラメータのデフォルトのレイアウトが表示されます。その他のほとんどのオブジェクトに、カスタム Operator やカスタム Shader など、正しく機能するための SPDL ファイルがあります。

各 ClassID に関連付けることができるのは 1 つの SPDL ファイルのみです。したがって、このメソッドを2度目に呼び出すと、1度目の呼び出しの結果は上書きされます。

CustomProperty の SPDL ファイルを作成するには XSIUtils.WriteSPDL を使用します。

この関数の呼び出しは、SPDL ファイル名を指定して"xsi -i"を呼び出す場合と非常に似ています。ただし、"xsi -i"とは異なり、SPDL ファイルは複製されません。SPDL ファイルとプリセットが.xsiaddon ファイルからインストールされると、登録は自動的に行われます。Workgroup 機能と同様に、SPDl の登録は自動で実行されます。したがって、通常はこのメソッドを呼び出す必要はありません。

また、このメソッドはプリセットファイルも生成できます。プリセットを使用すると、SceneItem.AddProperty の呼び出しでオブジェクトのインスタンスを作成できます。SPDL ファイルを変更する場合は、必ずプリセットファイルも生成することをお勧めします。プリセットファイルは SPDL ファイルの場所を基準とするパスで生成されるため、SPDL ファイルは必ずユーザ、ファクトリ、ワークグループ、ユーザアドオン、またはワークグループアドオンのディレクトリの Application/spdl ディレクトリに配置することをお勧めします。新しいプリセットを作成したり名前を変更したりできるため、複数のプリセットが同じオブジェクトを参照することもあり得ます。

C#構文

String XSIUtils.RegisterSPDL( String in_SpdlFileName, Boolean in_bGeneratePreset );

スクリプト構文

oString = XSIUtils.RegisterSPDL( SpdlFileName, [GeneratePreset] );

戻り値

GeneratePreset引数が true の場合、戻り値は新しいプリセットファイルのフルパスを含むStringになります。

パラメータ

パラメータ タイプ 説明
SpdlFileName string SPDL ファイルの名前。パスが含まれていない場合は、SPDL ファイルは[User Directory]¥Application¥spdl ディレクトリにあるものとみなされます。
GeneratePreset boolean SPDL ファイルに基づいてプリセットを生成するかどうか。

デフォルト値: false

JScript の例

// SPDL repair example

//

// This script scans for spdls and re-registers them.

// Normally it should not be necessary to run this

// script because Softimage itself performs a similar scan

// each time it starts.

//

// However it is a good example of using the FileSystemObject

// to recurse through directories and can be repurposed for

// other uses.

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

var g_oProgressBar = XSIUIToolkit.ProgressBar

var g_slash = "\\" ;

if ( Application.Platform != "Win32" )

{

	g_slash = "/" ;

}

SpdlRepair() ;

function SpdlRepair()

{

	var g_aSpdlList = new Array() ;

	// Use a progress bar in case it takes a long time

	// to scan the workgroup

	g_oProgressBar.maximum = 3

	g_oProgressBar.step = 1

	g_oProgressBar.visible = true

	g_oProgressBar.caption = "Processing SPDLs"

	// Scan workgroup (including workgroup addon location)

	// followed by factory addon, then user.  We don't scan the factory

	// itself because built-in spdls should not be registered with this

	// script.  Order of scanning is important because a local spdl should

	// take priority over remote spdls.

	if ( Application.InstallationPath( siWorkgroupPath ) != "" )

	{

		FindSpdls( Application.InstallationPath( siWorkgroupPath ), g_aSpdlList ) ;

	}

	// Factory addon location

	FindSpdls( Application.InstallationPath( siAddonPath ), g_aSpdlList ) ;

	// Look for local spdls

	FindSpdls( Application.InstallationPath( siUserPath ), g_aSpdlList ) ;

	g_oProgressBar.Increment() ;

	InstallSpdls( g_aSpdlList ) ;

	g_oProgressBar.Increment() ;

	Application.LogMessage( "Complete" ); 

}

// Recursively search for spdl files

function FindSpdls( in_root, io_list )

{

	g_oProgressBar.StatusText = in_root ;

	//Application.LogMessage( "Visiting " + in_root ) ;

	var oFolder = g_oFSO.GetFolder( in_root ) ;

	// Scan for spdl files in the current directory

	var oFiles = new Enumerator( oFolder.Files ) ;		

	for (;!oFiles.atEnd(); oFiles.moveNext())

	{

		var oFile = oFiles.item() ;

		var strFileName = oFile.Name ;

		var aElems = strFileName.split( "." ); 

		if ( aElems.length < 2 )

			continue ;

		// Check the extension

		if ( aElems[aElems.length-1].toLowerCase() != "spdl" )

			continue ;

		// Add the spdl to our list						

		io_list[ io_list.length ] = oFolder.Path + g_slash + strFileName ;

	}

	// Recurse into sub folders.  There are rules

// about the folders that a spdl can be stored at,

// e.g. \Application\spdl \Addons\Application\spdl

// \Addons\<subdir>\Application\spdl but

// in this case it is easier to do a brute force

// scan.  (This might cause problem if the user

// had manually copied backups of spdl files into 

// unexpected locations)

	var oSubFolders = new Enumerator( oFolder.SubFolders ) ;		

	for (;!oSubFolders.atEnd(); oSubFolders.moveNext())

	{

		var oSubFolder = oSubFolders.item() ;

		FindSpdls( oSubFolder.Path, io_list ) ;

	}		

}

function InstallSpdls( in_SpdlList )

{

	// Add each spdl to the registry

	for ( var i = 0 ; i < in_SpdlList.length ; i++ )

	{

		var bFailed = false; 

		try

		{

			XSIUtils.RegisterSpdl( in_SpdlList[i], false ) ;			

			Application.LogMessage( "Registered " + in_SpdlList[i] ) ;

		}

		catch( e )

		{

			bFailed = true ;

		}

		if ( bFailed )

		{

			var bSpdlCheckFailed = false; 

			try

			{

				// call spdl check.  (See the example with XSIUtils.LaunchProcess

				// for a better way to call spdlcheck.)

				system( "spdlcheck " + in_SpdlList[i] ) ;		

			}

			catch(e)

			{

				bSpdlCheckFailed = true ;

			}

			if ( bSpdlCheckFailed )

			{

				Application.LogMessage( "SPDL parsing error in " + in_SpdlList[i] + 

					" use spdlcheck for more info" ) ;

			}

			else

			{			

				// This could fail for various reasons 

				//- Current user doesn't have write access to the registry			

			    	//- missing dll for compiled shader or operator

				//- dll dependency problem (use depends.exe to track down)

				Application.LogMessage( "Failed to register " + in_SpdlList[i] ) ;

			}

		}		

	}		

}

関連項目

XSIUtils.UnregisterSPDL XSIUtils.WriteSPDL XSIUtils.Reload DataRepository.GetIdentifier SpdlCheck