FileFormat — Aspose.3D FOSS for Python API Reference

Properties

FileFormat đóng vai trò vừa là bộ mô tả định dạng vừa là một kho đăng ký của tất cả các định dạng tệp 3D được hỗ trợ. Mỗi định dạng được biểu diễn dưới dạng một FileFormat đối tượng có thể truy cập như một thuộc tính lớp hoặc thông qua các phương thức tĩnh của nhà máy. Bạn truyền FileFormat các đối tượng tới Scene.save() để ép buộc một định dạng cụ thể, hoặc sử dụng FileFormat.detect() để xác định định dạng của tệp không xác định.

Properties: aspose.threed

from aspose.threed import FileFormat

Các Hằng Số Định Dạng Được Hỗ Trợ

Các hằng số định dạng đang được hỗ trợ tích cực (các bộ nhập và/hoặc xuất đã đăng ký) trong bản phát hành FOSS được hiển thị bên dưới. Các hằng số được liệt kê là None trong mã nguồn là các tên được dành riêng cho các định dạng chưa được triển khai.

Được Hỗ Trợ Tích Cực (bản phát hành FOSS)

PropertiesPropertiesProperties
FileFormat.WAVEFRONT_OBJ().objPhương thức tĩnh trả về một ObjFormat đối tượng
FileFormat.GLTF2().gltf / .glbglTF 2.0; phương thức tĩnh trả về một GltfFormat đối tượng
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; phương thức tĩnh
FileFormat.MICROSOFT_3MF.3mf3MF (set at module load)
FileFormat.COLLADA.daeProperties
FileFormat.STL_BINARY.stlSTL binary (được đặt khi tải mô-đun)
FileFormat.STLASCII.stlSTL ASCII

Properties

FBX phiên bản 6100–7700 (binary), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binary, PDF, Blender, DXF, PLY, X (binary/text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binary.

Phương thức tĩnh

PropertiesKiểu trả vềProperties
FileFormat.detect(stream, file_name)`FileFormatNone`
FileFormat.get_format_by_extension(ext)`FileFormatNone`

Thuộc Tính Thể Hiện

PropertiesPropertiesProperties
extensionstrPhần mở rộng tệp chính (không có dấu chấm đầu)
extensionslist[str]Tất cả các phần mở rộng được hỗ trợ bởi định dạng này
content_typestrChuỗi loại MIME
can_exportboolCó hỗ trợ xuất sang định dạng này hay không
can_importboolCó hỗ trợ nhập từ định dạng này hay không
versionstrChuỗi phiên bản định dạng

Các phương thức của đối tượng

PropertiesKiểu trả vềProperties
create_load_options()LoadOptionsTạo ra định dạng‑cụ thể thích hợp LoadOptions lớp con
create_save_options()SaveOptionsTạo ra định dạng‑cụ thể thích hợp SaveOptions lớp con

Properties

from aspose.threed import Scene, FileFormat

# Auto-detect and load
scene = Scene.from_file("model.obj")

# Save with explicit format (force GLB binary)
from aspose.threed.formats import GltfSaveOptions
opts = GltfSaveOptions()
opts.binary_mode = True
scene.save("output.glb", opts)

# Get format by extension
fmt = FileFormat.get_format_by_extension(".fbx")
if fmt:
    print(fmt.can_import)   # True
    print(fmt.can_export)   # True

# Create options from a format instance
fmt_obj = FileFormat.get_format_by_extension(".obj")
load_opts = fmt_obj.create_load_options()   # ObjLoadOptions
save_opts = fmt_obj.create_save_options()   # ObjSaveOptions

# Detect format from file stream
with open("unknown_file.bin", "rb") as f:
    detected = FileFormat.detect(f, "unknown_file.bin")
    if detected:
        print(type(detected).__name__)

Xem thêm

 Tiếng Việt