SearchAndReplacePath

導入

v1.5

詳細

シーンで使用されるファイルへのファイル パスを更新します。 たとえば、ピクチャ ディレクトリの場所を変更する場合などです。 パスのリストを表示できるほか、[File]メニューから[Source Paths]を選択して外部ファイルを呼び出せます。

このコマンドは、特定カテゴリ内の全ファイル名を変更するか(例: すべてのピクチャ)、外部ファイル リスト内の各ファイル名を変更します。 引数が指定されない場合はプロパティ ページが表示され、値を入力するよう求められます。

スクリプト構文

SearchAndReplacePath( [Category], [OldString], [NewString], [CaseSensitive], [Files] );

パラメータ

パラメータ タイプ 説明
Category 文字列 変更するファイルのカテゴリ。 [File] > [Source Paths]ダイアログの[Category]列に対応します。

デフォルト値: All

指定可能な値:

説明:

All ExternalFilesListの全ファイル
Actions すべてのアクション ファイル(.eani)
オーディオ すべてのオーディオ ファイル(「.wav」、「.aiff」、「.mov」など)
Models すべてのモデル ファイル(.emdl)
MatLib すべてのマテリアルライブラリファイル(.xsi)
Pictures すべてのピクチャ ファイル(「.pic」、「.tga」、「.gif」など)
Render_Pictures レンダリング用のすべてのピクチャ(例: HDR)
シノプティック すべてのシノプティックファイル(.htm、.html)
Thumbnails すべてのサムネイル ファイル
OldString 文字列 指定のパス内を検索する文字列。 ディレクトリ名(例: 「c:¥users¥fillet¥src」の「fillet」)、パス全体(例: 「c:¥users¥fillet¥src」)、またはディレクトリの一部の文字列(例: 「c:¥users¥fillet¥src」の「fill」)を使用できます。

デフォルト値:このパラメータが指定されていない場合はプロパティページが開き、入力するよう求められます

NewString 文字列 OldString を指定のパスに置き換える文字列

デフォルト値:このパラメータが指定されていない場合はプロパティページが開き、入力するよう求められます

CaseSensitive Boolean 大文字小文字を区別して検索置換する場合は True

デフォルト値: False

Files XSICollection 処理するFileReferenceオブジェクトのコレクション。 何も指定されていない場合は、シーンが使用するすべての外部ファイルが処理されます。 つまり、[External File Manager]ダイアログによって使用されるファイルです。

JScript の例

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

//

// This example demonstrates how to search and replace a portion of

// the path in the external file list.

//

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

NewScene( null, false );

// First add the no_icon pic to the external file list by adding a texture

CreatePrim( "Sphere", "MeshSurface" );

BlendInPresets( null, null, 0, true, siReplaceNoBlend );

var oExternalFileList = GetValue( "Project.ExternalFilesList" );

// Print current external file list before SearchAndReplacePath

Application.LogMessage( "Original paths:" );

for ( var i=0; i< oExternalFileList.Count; i++ ) {

	Application.LogMessage( oExternalFileList.Item(i) );

}

// Change the pictures (only 1 in this case) to a new name which will be invalid

SearchAndReplacePath( "Pictures", "noIcon", "missingIcon" );

// Print replaced external file list

oExternalFileList = GetValue( "Project.ExternalFilesList" );

Application.LogMessage( "Changed paths:" );

for (i=0; i< oExternalFileList.Count; i++) {

	Application.LogMessage( oExternalFileList.Item(i) );

}

// Change back the pictures to the original filename.

SearchAndReplacePath( "Pictures", "missing", "no" );

// Print restored external file list

oExternalFileList = GetValue( "Project.ExternalFilesList" );

Application.LogMessage( "Restored paths:" );

for ( i=0; i< oExternalFileList.Count; i++ )

{

	Application.LogMessage( oExternalFileList.Item(i) );

}

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

// Output of above script:

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

// INFO : Original paths:

// INFO : $XSI_HOME/Application/rsrc/noIcon.pic

// INFO : Changing $XSI_HOME/Application/rsrc/noIcon.pic To $XSI_HOME/Application/rsrc/missingIcon.pic

// INFO : Changed paths:

// INFO : $XSI_HOME/Application/rsrc/missingIcon.pic

// INFO : Changing $XSI_HOME/Application/rsrc/missingIcon.pic To $XSI_HOME/Application/rsrc/noIcon.pic

// INFO : Restored paths:

// INFO : $XSI_HOME/Application/rsrc/noIcon.pic

関連項目

FileReference Scene.GetExternalFile