Model.ExternalFiles プロパティまたは Model::GetExternalFiles メンバ関数または Scene.ExternalFiles プロパティまたは Scene::GetExternalFiles メンバ関数 によって、シーンまたはシーンまたはモデルまたはモデルで参照される各外部ファイルを表す FileReferenceCollection または FileReference オブジェクトの CRefArray を取得できます。これらの FileReference または FileReference オブジェクトは、それらが参照される場所に存在するかどうかに関係なく使用でき、FileReference.FileExists メソッドまたは FileReference::FileExists メンバー関数によってテストできます。
Python の例: モデルにある外部ファイルのリストを取得する
この例では、特定のモデルにある外部ファイルのリストを取得する方法を示します。
from win32com.client import constants as c
app = Application
app.NewScene("", 0)
root = app.ActiveSceneRoot
# ---------------------------------------------------------------------------
# CONVENIENCE FUNCTION
#
def printFileInfo( in_file ) :
# Get the original path
orig_path = in_file.Name
app.LogMessage( "FileType: " + in_file.FileType )
if in_file.FileExists() :
app.LogMessage( in_file.Name + " exists" )
# Get the resolved path
rslv_path = in_file.ResolvedPath
# Get the UNC path
unc_path = in_file.UNCPath
# Print all three results
app.LogMessage( "ORIGINAL: " + orig_path )
app.LogMessage( "RESOLVED: " + rslv_path )
app.LogMessage( "UNC : " + unc_path )
else :
app.LogMessage( "Specified FileReference does NOT exist" )
# ---------------------------------------------------------------------------
# MAIN
#
# First import a model so we have some external files to find
FPath = app.InstallationPath( c.siFactoryPath )
refModels = app.ImportRefModels( XSIUtils.BuildPath(FPath, "Data", "XSI_SAMPLES", "Models", "Man_Face.emdl") )
# Enumerate all files related to this model
oModel = root.Models(0)
extFileList = oModel.ExternalFiles
for file in extFileList :
printFileInfo( file )
# ---------------------------------------------------------------------------
# OUTPUT
#
# INFO : FileType: Models
# INFO : E:\Softimage\Softimage_2013\Data\XSI_SAMPLES\Models\Man_Face.emdl exists
# INFO : ORIGINAL: C:\Softimage\Softimage_2013\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : RESOLVED: C:\Softimage\Softimage_2013\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : UNC : C:\Softimage\Softimage_2013\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : FileType: Models
# INFO : Specified FileReference does NOT exist