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ディレクトリに配置することをお勧めします。新しいプリセットを作成したり名前を変更したりできるため、複数のプリセットが同じオブジェクトを参照することもあり得ます。
oString = XSIUtils.RegisterSPDL( SpdlFileName, [GeneratePreset] ); |
GeneratePreset引数が true の場合、戻り値は新しいプリセットファイルのフルパスを含むStringになります。
パラメータ | タイプ | 詳細 |
---|---|---|
SpdlFileName | string | SPDL ファイルの名前。パスが含まれていない場合は、SPDL ファイルは[User Directory]¥Application¥spdlディレクトリにあるものとみなされます。 |
GeneratePreset | boolean | SPDL ファイルに基づいてプリセットを生成するかどうか。
デフォルト値: false |
// 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] ) ; } } } } |