Load and Save Options — Aspose.3D FOSS for Python API Reference
Tất cả các thao tác nhập và xuất chấp nhận một đối tượng tùy chọn được suy ra từ LoadOptions hoặc SaveOptions. Gửi lớp con thích hợp tới Scene.open() hoặc Scene.save() để kiểm soát hành vi đặc thù của định dạng.
: aspose.threed.formats
from aspose.threed.formats import (
LoadOptions, SaveOptions,
ObjLoadOptions, ObjSaveOptions,
GltfLoadOptions, GltfSaveOptions,
StlLoadOptions, StlSaveOptions,
FbxLoadOptions, FbxSaveOptions,
ColladaLoadOptions, ColladaSaveOptions,
ThreeMfLoadOptions, ThreeMfSaveOptions,
)LoadOptions và SaveOptions kế thừa từ IOConfig. Các thuộc tính sau có sẵn trên mọi đối tượng tùy chọn.file_format | `FileFormat | None` |
encoding | `str | None` |
file_system | `FileSystem | None` |
lookup_paths | list[str] | Các thư mục bổ sung để tìm kiếm khi giải quyết các tham chiếu bên ngoài |
file_name | `str | None` |
LoadOptions
Lớp cơ sở cho tất cả các đối tượng tùy chọn tải.
Thuộc tính bổ sung (beyond IOConfig):
encoding | `str | None` |
SaveOptions
Lớp cơ sở cho tất cả các đối tượng tùy chọn lưu.
Thuộc tính bổ sung (beyond IOConfig):
export_textures | bool | True, các texture được tham chiếu bởi cảnh sẽ được sao chép vào đầu ra. Mặc định là False |
ObjLoadOptions
Tùy chọn tải cho các tệp Wavefront OBJ (.obj).
from aspose.threed.formats import ObjLoadOptions
opts = ObjLoadOptions()
opts.flip_coordinate_system = True
opts.scale = 0.01
scene = Scene()
scene.open("model.obj", opts)flip_coordinate_system | bool | False | Đảo ngược hệ tọa độ khi nhập |
enable_materials | bool | True | Tải tệp đi kèm .mtl tệp vật liệu |
scale | float | 1.0 | Tỷ lệ đồng nhất được áp dụng cho tất cả geometry đã nhập |
normalize_normal | bool | True | Chuẩn hoá các vector pháp tuyến đã nhập về độ dài đơn vị |
ObjSaveOptions
Tùy chọn lưu cho các tệp Wavefront OBJ.
from aspose.threed.formats import ObjSaveOptions
opts = ObjSaveOptions()
opts.enable_materials = False
scene.save("output.obj", opts)apply_unit_scale | bool | False | Áp dụng hệ số tỷ lệ đơn vị của cảnh vào các tọa độ đã xuất |
point_cloud | bool | False | Chỉ xuất các đỉnh (không có mặt đa giác) |
verbose | bool | False | Bao gồm các chú thích OBJ bổ sung trong đầu ra |
serialize_w | bool | False | Ghi thành phần W của các điểm điều khiển |
enable_materials | bool | True | Ghi một .mtl tệp vật liệu và tham chiếu nó từ .obj |
flip_coordinate_system | bool | False | Đảo ngược hệ tọa độ khi xuất |
axis_system | `AxisSystem | None` | None |
GltfLoadOptions
Tùy chọn tải cho các tệp glTF 2.0 và GLB (.gltf, .glb).
from aspose.threed.formats import GltfLoadOptions
opts = GltfLoadOptions()
opts.flip_tex_coord_v = False
scene = Scene()
scene.open("model.gltf", opts)flip_tex_coord_v | bool | True | Đảo ngược tọa độ texture V khi nhập (glTF sử dụng gốc trên‑trái; True chuyển sang dưới‑trái) |
GltfSaveOptions
Tùy chọn lưu cho đầu ra glTF 2.0.
from aspose.threed.formats import GltfSaveOptions
opts = GltfSaveOptions()
opts.binary_mode = True # produce a .glb file
scene.save("output.glb", opts)binary_mode | bool | False | True, ghi một GLB nhị phân tự chứa; khi False, ghi JSON .gltf với bộ đệm bên ngoài |
flip_tex_coord_v | bool | True | Lật ngược tọa độ V của texture khi xuất |
export_textures | bool | False | Sao chép các texture được tham chiếu vào gói đầu ra (kế thừa từ SaveOptions) |
StlLoadOptions
Tùy chọn tải cho tệp STL (.stl).
from aspose.threed.formats import StlLoadOptions
opts = StlLoadOptions()
opts.scale = 0.001 # convert millimetres to metres
scene = Scene()
scene.open("part.stl", opts)flip_coordinate_system | bool | False | Đảo ngược hệ tọa độ khi nhập |
scale | float | 1.0 | Tỷ lệ đồng nhất được áp dụng cho hình học đã nhập |
StlSaveOptions
Tùy chọn lưu cho đầu ra STL.
from aspose.threed.formats import StlSaveOptions
opts = StlSaveOptions()
opts.binary_mode = True
scene.save("output.stl", opts)flip_coordinate_system | bool | False | Đảo ngược hệ tọa độ khi xuất |
scale | float | 1.0 | Tỷ lệ đồng nhất được áp dụng cho hình học đã xuất |
binary_mode | bool | False | Ghi STL nhị phân thay vì STL ASCII |
FbxLoadOptions
Tùy chọn tải cho tệp FBX (.fbx).
from aspose.threed.formats import FbxLoadOptions
opts = FbxLoadOptions()
opts.keep_builtin_global_settings = True
scene = Scene()
scene.open("animation.fbx", opts)keep_builtin_global_settings | bool | False | Bảo tồn FBX GlobalSettings các thuộc tính trong thông tin tài sản cảnh |
compatible_mode | bool | False | Bật chế độ tương thích cho các tệp FBX từ các công cụ tạo nội dung cũ hơn |
FbxSaveOptions
Tùy chọn lưu cho đầu ra FBX.
from aspose.threed.formats import FbxSaveOptions
opts = FbxSaveOptions()
opts.enable_compression = False
scene.save("output.fbx", opts)export_textures | bool | False | Sao chép các texture được tham chiếu vào thư mục đầu ra |
reuse_primitive_mesh | bool | False | Loại bỏ trùng lặp hình học lưới giống nhau trong đầu ra |
enable_compression | bool | True | Bật nén nội bộ FBX nhị phân |
fold_repeated_curve_data | None | Gộp các đoạn đường cong hoạt hình giống nhau | |
export_legacy_material_properties | bool | True | Bao gồm các thành phần kế thừa Phong/Lambert các nút thuộc tính vật liệu để tương thích |
video_for_texture | bool | False | Nhúng dữ liệu texture vào các nút video FBX |
embed_textures | bool | False | Nhúng các tệp texture trực tiếp trong nhị phân FBX |
generate_vertex_element_material | bool | False | Thêm một VertexElementMaterial lớp cho việc gán vật liệu cho mỗi đa giác |
ColladaLoadOptions
Tùy chọn tải cho các tệp COLLADA (.dae).
from aspose.threed.formats import ColladaLoadOptions
opts = ColladaLoadOptions()
opts.scale = 0.01
scene = Scene()
scene.open("model.dae", opts)flip_coordinate_system | bool | False | Đảo ngược hệ tọa độ khi nhập |
enable_materials | bool | True | Nhập định nghĩa vật liệu COLLADA |
scale | float | 1.0 | Áp dụng tỉ lệ đồng nhất cho hình học đã nhập |
normalize_normal | bool | True | Chuẩn hoá các vector pháp tuyến đã nhập |
ColladaSaveOptions
Tùy chọn lưu cho đầu ra COLLADA.
from aspose.threed.formats import ColladaSaveOptions
opts = ColladaSaveOptions()
opts.indented = False # compact output
scene.save("output.dae", opts)flip_coordinate_system | bool | False | Đảo ngược hệ tọa độ khi xuất |
enable_materials | bool | True | Ghi định nghĩa vật liệu COLLADA |
indented | bool | True | In đẹp đầu ra XML với thụt lề |
ThreeMfLoadOptions / ThreeMfSaveOptions
Tùy chọn tải và lưu cho các tệp 3MF (.3mf).
from aspose.threed.formats import ThreeMfLoadOptions, ThreeMfSaveOptions
# Load
load_opts = ThreeMfLoadOptions()
scene = Scene()
scene.open("part.3mf", load_opts)
# Save
save_opts = ThreeMfSaveOptions()
scene.save("output.3mf", save_opts)Các lớp này kế thừa các thuộc tính cơ bản từ LoadOptions / SaveOptions tương ứng. Không có thuộc tính đặc thù cho định dạng nào được tài liệu hoá cho bản phát hành FOSS hiện tại.