FileFormat — Aspose.3D FOSS for .NET
Example
Example FileFormat class는 지원되는 모든 3D 파일 형식의 레지스트리입니다. 개별 형식에 대한 공개된 명명된 상수는 없으며 — 형식 인스턴스는 정적 탐색 메서드를 통해 런타임에 얻어지거나 the Formats 컬렉션.
형식 레지스트리
지원 형식은 내부적으로 등록됩니다. 다음 API를 사용하여 접근하십시오:
| Example | Example | Example |
|---|---|---|
FileFormat.Formats | IList<FileFormat> | 모든 등록된 형식 인스턴스 |
FileFormat.Detect(string filePath) | FileFormat | 파일 경로(확장자 및 내용)를 통해 형식을 감지합니다 |
FileFormat.GetFormatByExtension(string ext) | FileFormat | 주어진 파일 확장자에 대한 형식을 반환합니다(예:. ".obj") |
등록된 형식에는 OBJ, STL, glTF/GLB, FBX, COLLADA, PLY, 3MF가 포함됩니다.
Example
| Example | 반환 타입 | Example |
|---|---|---|
Detect(string filePath) | FileFormat | 파일 경로에서 형식을 감지합니다 |
GetFormatByExtension(string ext) | FileFormat | 확장자와 일치하는 형식을 반환합니다 |
CreateLoadOptions() | LoadOptions | 이 형식 인스턴스에 적합한 로드 옵션을 반환합니다 |
CreateSaveOptions() | SaveOptions | 이 형식 인스턴스에 적합한 저장 옵션을 반환합니다 |
다음에 대한 참고 CreateLoadOptions() / CreateSaveOptions(): 이 메서드들은 다음과 같은 경우에 올바르게 작동합니다 에 의해 반환된 형식 인스턴스에 호출될 때 Detect() 또는 GetFormatByExtension() — 각각 등록된 포맷은 자체 구현으로 이러한 메서드를 재정의합니다. 원시 기본 클래스에서 이를 호출하면 FileFormat 인스턴스(레지스트리를 통해 얻지 않은)에서 예외를 발생시킵니다 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.Name}: import={fmt.CanImport}, export={fmt.CanExport}");