ImportCustomFile

Introduced

v8.0 (2010)

Categories

File

Description

Imports the contents of the specified custom file into the scene . The custom file type must be registered in an import custom converter event (see PluginRegistrar.RegisterConverterEvent for more information about how to specify the extension of the filename).

This command fires the following events: siOnBeginFileImport, the custom importer registered for the matching file extension, and siOnEndFileImport, in that order.

The FileType context attribute of the siOnBeginFileImport, siOnCustomFileImport and siOnEndFileImport events will have the siFileTypeCustom value when this command is called.

Warning: If there is no custom importer event registered with the matching file extension, the command will fail and an error will be logged.

Scripting Syntax

ImportCustomFile( FileName, [Target], [Reference], [Name], [Frame], [UserData] );

Parameters

Parameter Type Description
FileName String The full path name of the custom file to import.
Target String The parent of the content imported from the custom file.

Default Value: Scene_Root

Reference Boolean Specifies whether a reference model is being imported, if applicable. This information is only accessible from the Reference context attribute for the siOnBeginFileImport and siOnEndFileImport events.

Default Value: False

Name String The name of the reference model created during the import. This information is only accessible from the Name context attribute for the siOnBeginFileImport and siOnEndFileImport events.

Default Value: ""

Frame Integer Frame at which to import the contents of the custom file. This information is only accessible from the custom converter import event callback.

Default Value: Current frame.

UserData Parameter-dependent Any data that needs to be accessible from the custom converter import event callback.

Examples

JScript Example

/*
        First of all, an import converter event must be registered with the extension of the file to import.
*/
function XSILoadPlugin( in_reg )
{
        in_reg.Author = "ABC" ;
        in_reg.Name = "ABC Text Converter plugin" ;
        in_reg.Major = 1;
        in_reg.Minor = 0;
        in_reg.URL = "www.abc.com"
        // Let XSI know that this plug-in implements custom import/export events for ABC files
        in_reg.RegisterConverterEvent("ABCTextImport",siOnCustomFileImport, "ABC");
        in_reg.RegisterConverterEvent("ABCTextExport",siOnCustomFileExport, "ABC");
        return true ;
}
function ABCTextImport_OnEvent( in_ctxt )
{
        Application.LogMessage("ABC Text Import Event called...");
        Application.LogMessage("FileName: " + in_ctxt.GetAttribute("FileName"));
        Application.LogMessage("Target: " + in_ctxt.GetAttribute("Target"));
        Application.LogMessage("FileType: " + in_ctxt.GetAttribute("FileType"));
        Application.LogMessage("Frame: " + in_ctxt.GetAttribute("Frame"));
        Application.LogMessage("UserData: " + in_ctxt.GetAttribute("UserData"));
}
function ABCTextExport_OnEvent( in_ctxt )
{
        Application.LogMessage("ABC Text Export Event called...");
        Application.LogMessage("FileName: " + in_ctxt.GetAttribute("FileName"));
        Application.LogMessage("Target: " + in_ctxt.GetAttribute("Target"));
        Application.LogMessage("FileType: " + in_ctxt.GetAttribute("FileType"));
        Application.LogMessage("Frame: " + in_ctxt.GetAttribute("Frame"));
        Application.LogMessage("UserData: " + in_ctxt.GetAttribute("UserData"));
}
/*
        Then, the ImportCustomFile command may be called from any script.
*/
ImportCustomFile("MyABCfile.abc", "Scene_Root", false, "myImportFile", 40, "ABCImportOptions");
//---------------------------------------------------------
// Output from this script:
// INFO : ABC Text Import Event called...
// INFO : FileName: MyABCfile.abc
// INFO : Target: Scene_Root
// INFO : FileType: 31
// INFO : Frame: 40
// INFO : UserData: ABCImportOptions
//---------------------------------------------------------

See Also

ExportCustomFile