FileFormat
Phương pháp
Methods FileFormat class là một kho đăng ký của tất cả các định dạng tệp 3D được hỗ trợ. Không có hằng số công khai có tên cho từng định dạng — các thể hiện định dạng được lấy tại thời gian chạy thông qua các phương thức khám phá tĩnh hoặc Formats bộ sưu tập.
Danh bạ Định dạng
Các định dạng được hỗ trợ được đăng ký nội bộ. Sử dụng API sau để truy cập chúng:
| Name | Type | Access | Description |
|---|---|---|---|
Formats | IList<FileFormat> | Read | Gets the formats. |
Version | Version | Read | Gets the version. |
CanExport | bool | Read | Gets the can export. |
CanImport | bool | Read | Gets the can import. |
Extension | string | Read | Gets the extension. |
Extensions | string[] | Read | Gets the extensions. |
ContentType | FileContentType | Read | Gets the content type. |
FileFormatType | FileFormatType | Read | Gets the file format type. |
FBX | FileFormat | Read | Gets the fbx. |
OBJ | FileFormat | Read | Gets the obj. |
STL | FileFormat | Read | Gets the stl. |
GLTF | FileFormat | Read | Gets the gltf. |
GLTF_Binary | FileFormat | Read | Gets the gltf binary. |
PDF | Formats.PdfFormat | Read | Gets the pdf. |
PLY | Formats.PlyFormat | Read | Gets the ply. |
Microsoft3MF | Formats.Microsoft3MFFormat | Read | Gets the microsoft3 mf. |
Draco | Formats.DracoFormat | Read | Gets the draco. |
RvmText | Formats.RvmFormat | Read | Gets the rvm text. |
RvmBinary | Formats.RvmFormat | Read | Gets the rvm binary. |
Blender | FileFormat | Read | Gets the blender. |
DXF | FileFormat | Read | Gets the dxf. |
XBinary | FileFormat | Read | Gets the x binary. |
XText | FileFormat | Read | Gets the x text. |
ASE | FileFormat | Read | Gets the ase. |
IFC | FileFormat | Read | Gets the ifc. |
SiemensJT8 | FileFormat | Read | Gets the siemens jt8. |
SiemensJT9 | FileFormat | Read | Gets the siemens jt9. |
AMF | FileFormat | Read | Gets the amf. |
VRML | FileFormat | Read | Gets the vrml. |
Aspose3DWeb | FileFormat | Read | Gets the aspose3 d web. |
HTML5 | FileFormat | Read | Gets the html5. |
Zip | FileFormat | Read | Gets the zip. |
USD | FileFormat | Read | Gets the usd. |
USDA | FileFormat | Read | Gets the usda. |
USDZ | FileFormat | Read | Gets the usdz. |
Xyz | FileFormat | Read | Gets the xyz. |
Pcd | FileFormat | Read | Gets the pcd. |
PcdBinary | FileFormat | Read | Gets the pcd binary. |
Các định dạng đã đăng ký bao gồm: OBJ, STL, glTF/GLB, FBX, COLLADA, PLY và 3MF.
Phương pháp
| Signature | Description |
|---|---|
CanDetect(stream: Stream, fileName: string?) | True if this format can handle the file |
GetFormatByExtension(extensionName: string) | Gets the preferred file format from the file extension name The extension name should starts with a dot(’.’). |
Detect(fileName: string) | Detects file format from file name, file must be readable so Aspose.3D can detect file format through file header. |
Detect(stream: Stream, fileName: string) | Detects file format from file name, file must be readable so Aspose.3D can detect file format through file header. |
CreateLoadOptions() | Not implemented in the FOSS edition — throws at runtime. Creates a default load options object for this format |
CreateSaveOptions() | Not implemented in the FOSS edition — throws at runtime. Creates a default save options object for this format |
ToString() | Formats to string |
Ghi chú về CreateLoadOptions() / CreateSaveOptions(): Các phương thức này hoạt động chính xác khi được gọi trên các thể hiện định dạng được trả về bởi Detect() hoặc GetFormatByExtension() — mỗi định dạng đã đăng ký định dạng ghi đè các phương thức này bằng triển khai riêng của nó. Gọi chúng trên một lớp cơ sở thô FileFormat thể hiện (không được lấy qua registry) sẽ ném ra NotImplementedException.
Phương pháp
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}");