Load and Save Options

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,
)

LoadOptionsSaveOptions 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`FileFormatNone`
encoding`strNone`
file_system`FileSystemNone`
lookup_pathslist[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`strNone`

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`strNone`

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_texturesbool
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_systemboolFalseĐảo ngược hệ tọa độ khi nhập
enable_materialsboolTrueTải tệp đi kèm .mtl tệp vật liệu
scalefloat1.0Tỷ lệ đồng nhất được áp dụng cho tất cả geometry đã nhập
normalize_normalboolTrueChuẩ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_scaleboolFalseÁp dụng hệ số tỷ lệ đơn vị của cảnh vào các tọa độ đã xuất
point_cloudboolFalseChỉ xuất các đỉnh (không có mặt đa giác)
verboseboolFalseBao gồm các chú thích OBJ bổ sung trong đầu ra
serialize_wboolFalseGhi thành phần W của các điểm điều khiển
enable_materialsboolTrueGhi một .mtl tệp vật liệu và tham chiếu nó từ .obj
flip_coordinate_systemboolFalseĐảo ngược hệ tọa độ khi xuất
axis_system`AxisSystemNone`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_vboolTrueĐả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_modeboolFalse
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_vboolTrueLật ngược tọa độ V của texture khi xuất
export_texturesboolFalseSao 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_systemboolFalseĐảo ngược hệ tọa độ khi nhập
scalefloat1.0Tỷ 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_systemboolFalseĐảo ngược hệ tọa độ khi xuất
scalefloat1.0Tỷ lệ đồng nhất được áp dụng cho hình học đã xuất
binary_modeboolFalseGhi 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_settingsboolFalseBảo tồn FBX GlobalSettings các thuộc tính trong thông tin tài sản cảnh
compatible_modeboolFalseBậ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_texturesboolFalseSao chép các texture được tham chiếu vào thư mục đầu ra
reuse_primitive_meshboolFalseLoại bỏ trùng lặp hình học lưới giống nhau trong đầu ra
enable_compressionboolTrueBật nén nội bộ FBX nhị phân
fold_repeated_curve_data
NoneGộp các đoạn đường cong hoạt hình giống nhau
export_legacy_material_propertiesboolTrueBao 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_textureboolFalseNhúng dữ liệu texture vào các nút video FBX
embed_texturesboolFalseNhúng các tệp texture trực tiếp trong nhị phân FBX
generate_vertex_element_materialboolFalseThê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_systemboolFalseĐảo ngược hệ tọa độ khi nhập
enable_materialsboolTrueNhập định nghĩa vật liệu COLLADA
scalefloat1.0Áp dụng tỉ lệ đồng nhất cho hình học đã nhập
normalize_normalboolTrueChuẩ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_systemboolFalseĐảo ngược hệ tọa độ khi xuất
enable_materialsboolTrueGhi định nghĩa vật liệu COLLADA
indentedboolTrueIn đẹ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.


Xem thêm

 Tiếng Việt