Getting External File Information

You can get a list of files representing each external file referenced in the scene or model via Model.ExternalFiles or Scene.ExternalFiles. These FileReference objects are available whether they exist in the referenced location or not, which you can test with FileExists.

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_7.5\Data\XSI_SAMPLES\Models\Man_Face.emdl exists
# INFO : ORIGINAL: C:\Softimage\Softimage_7.5\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : RESOLVED: C:\Softimage\Softimage_7.5\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : UNC     : C:\Softimage\Softimage_7.5\Data\XSI_SAMPLES\Models\Man_Face.emdl
# INFO : FileType: Models
# INFO : Specified FileReference does NOT exist


Autodesk Softimage v7.5