FileFormat — Aspose.3D FOSS for .NET

Overview

The FileFormat class is a registry of all supported 3D file formats. There are no public named constants for individual formats — format instances are obtained at runtime through the static discovery methods or the Formats collection.

Format Registry

Supported formats are registered internally. Use the following API to access them:

MemberTypeDescription
FileFormat.FormatsIList<FileFormat>All registered format instances
FileFormat.Detect(string filePath)FileFormatDetects format from a file path (by extension and content)
FileFormat.GetFormatByExtension(string ext)FileFormatReturns the format for a given file extension (e.g. ".obj")

Registered formats include: OBJ, STL, glTF/GLB, FBX, COLLADA, PLY, and 3MF.

Methods

MethodReturn TypeDescription
Detect(string filePath)FileFormatDetects the format from a file path
GetFormatByExtension(string ext)FileFormatReturns the format matching the extension
CreateLoadOptions()LoadOptionsReturns load options appropriate for this format instance
CreateSaveOptions()SaveOptionsReturns save options appropriate for this format instance

Note on CreateLoadOptions() / CreateSaveOptions(): These methods work correctly when called on format instances returned by Detect() or GetFormatByExtension() — each registered format overrides these methods with its own implementation. Calling them on a raw base-class FileFormat instance (not obtained through the registry) throws NotImplementedException.

Example

using Aspose.ThreeD;
using Aspose.ThreeD.Formats;

// Detect format from a file path
var format = FileFormat.Detect("model.obj");
Console.WriteLine(format.Extension); // ".obj"

// Get load options from the detected format instance
var loadOpts = format.CreateLoadOptions(); // returns ObjLoadOptions via polymorphism

// Load and save — format inferred from extension
var scene = new Scene();
scene.Open("model.obj");
scene.Save("output.glb");  // binary GLB inferred from .glb extension

// Enumerate all registered formats
foreach (var fmt in FileFormat.Formats)
    Console.WriteLine($"{fmt.Extension}: import={fmt.CanImport}, export={fmt.CanExport}");

See Also