FileFormat — Aspose.3D FOSS for .NET
Methods
Methods 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.
Formatregister
Ondersteunde formaten worden intern geregistreerd. Gebruik de volgende API om ze te benaderen:
| Methods | Methods | Methods |
|---|---|---|
FileFormat.Formats | IList<FileFormat> | All registered format instances |
FileFormat.Detect(string filePath) | FileFormat | Detects format from a file path (by extension and content) |
FileFormat.GetFormatByExtension(string ext) | FileFormat | Returns the format for a given file extension (e.g. ".obj") |
Geregistreerde formaten omvatten: OBJ, STL, glTF/GLB, FBX, COLLADA, PLY en 3MF.
Methods
| Methods | Return Type | Methods |
|---|---|---|
Detect(string filePath) | FileFormat | Detects the format from a file path |
GetFormatByExtension(string ext) | FileFormat | Returns the format matching the extension |
CreateLoadOptions() | LoadOptions | Returns load options appropriate for this format instance |
CreateSaveOptions() | SaveOptions | Returns 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 (niet verkregen via het register) gooit NotImplementedException.
Methods
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}");