You can get a FileReferenceCollection or CRefArray of FileReference objects representing each external file referenced in the scene or scene or model or model via Model.ExternalFiles property or Model::GetExternalFiles member function or Scene.ExternalFiles property or Scene::GetExternalFiles member function. These FileReference or FileReference objects are available whether they exist in the referenced location or not, which you can test with FileReference.FileExists method or FileReference::FileExists member function.
Python Example: Getting the List of External Files on a Model
This example demonstrates how to get the list of external files on a specific model.
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_2012\Data\XSI_SAMPLES\Models\Man_Face.emdl exists
# INFO : ORIGINAL: C:\Softimage\Softimage_2012\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : RESOLVED: C:\Softimage\Softimage_2012\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : UNC : C:\Softimage\Softimage_2012\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : FileType: Models
# INFO : Specified FileReference does NOT exist