/*
This JScript example demonstrates how to get the external file matching the specified GUID
*/
NewScene (0, false);
// First import a model so we have some external files to find
var FPath = InstallationPath( siFactoryPath );
ImportModel( FPath + "\\Data\\XSI_SAMPLES\\Models\\Man_Face.emdl", null, true );
// Get the GUID of the first file related to the current (active) scene
var oFilePath = Application.ActiveProject.ActiveScene.ExternalFiles(0);
printFileInfo( oFilePath );
var sGuid = oFilePath.GUID;
// Use that GUID to get the same object
var oFilePath2 = Application.ActiveProject.ActiveScene.GetExternalFile( sGuid );
// The 2 filespaths are the same!
printFileInfo( oFilePath2 );
// Expected result (your GUIDs will be different from the ones below, of course):
//INFO : FileType: Pictures
//INFO : FileExists: 1
//INFO : ORIGINAL: <factory location>\Application\rsrc\noIcon.pic
//INFO : RESOLVED: <factory location>\Application\rsrc\noIcon.pic
//INFO : UNC : <factory location>\Application\rsrc\noIcon.pic
//INFO : GUID : {C3416DDC-F75C-421F-9415-CD689DE8DF37}
//INFO : FileType: Pictures
//INFO : FileExists: 1
//INFO : ORIGINAL: <factory location>\Application\rsrc\noIcon.pic
//INFO : RESOLVED: <factory location>\Application\rsrc\noIcon.pic
//INFO : UNC : <factory location>\Application\rsrc\noIcon.pic
//INFO : GUID : {C3416DDC-F75C-421F-9415-CD689DE8DF37}
// Helper function to print info about the specified FileReference object
function printFileInfo( in_file ) {
// Verifying that this is a good object
LogMessage( "FileType: " + in_file.FileType );
LogMessage( "FileExists: " + in_file.FileExists() );
// Get the original path
var o_path = in_file;
// Get the resolved path
var r_path = o_path.ResolvedPath;
// Get the UNC path
var u_path = o_path.UNCPath;
// Get the GUID
var s_GUID = o_path.GUID;
// Print all results
LogMessage( "ORIGINAL: " + o_path );
LogMessage( "RESOLVED: " + r_path );
LogMessage( "UNC : " + u_path );
LogMessage( "GUID : " + s_GUID );
} |