Load and Save Options — Aspose.3D FOSS for Python API Reference
所有导入和导出操作接受一个可选的、派生自 LoadOptions 或 SaveOptions.。将适当的子类传递给 Scene.open() 或 Scene.save() 用于控制特定格式的行为。.
: aspose.threed.formats
from aspose.threed.formats import (
LoadOptions, SaveOptions,
ObjLoadOptions, ObjSaveOptions,
GltfLoadOptions, GltfSaveOptions,
StlLoadOptions, StlSaveOptions,
FbxLoadOptions, FbxSaveOptions,
ColladaLoadOptions, ColladaSaveOptions,
ThreeMfLoadOptions, ThreeMfSaveOptions,
)LoadOptions 和 SaveOptions 继承自 IOConfig. 以下属性在每个 options 对象上均可用。.file_format | `FileFormat | None` |
encoding | `str | None` |
file_system | `FileSystem | None` |
lookup_paths | list[str] | 解析外部引用时要搜索的额外目录 |
file_name | `str | None` |
LoadOptions
所有加载选项对象的基类。.
附加属性 (超出 IOConfig):
encoding | `str | None` |
SaveOptions
所有保存选项对象的基类。.
附加属性 (超出 IOConfig):
export_textures | bool | True, 场景引用的纹理会被复制到输出中。默认是 False |
ObjLoadOptions
加载 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 | 导入时翻转坐标系 |
enable_materials | bool | True | 加载随附的 .mtl 材质文件 |
scale | float | 1.0 | 对所有导入的几何体应用统一缩放 |
normalize_normal | bool | True | 将导入的法向量归一化为单位长度 |
ObjSaveOptions
Wavefront OBJ 文件的保存选项。.
from aspose.threed.formats import ObjSaveOptions
opts = ObjSaveOptions()
opts.enable_materials = False
scene.save("output.obj", opts)apply_unit_scale | bool | False | 将场景的单位缩放因子应用于导出的坐标 |
point_cloud | bool | False | 仅导出顶点(不包括多边形面) |
verbose | bool | False | 在输出中包含额外的 OBJ 注释 |
serialize_w | bool | False | 写入控制点的 W 分量 |
enable_materials | bool | True | 写入 a .mtl material 文件并从中引用它 .obj |
flip_coordinate_system | bool | False | 在导出时翻转坐标系 |
axis_system | `AxisSystem | None` | None |
GltfLoadOptions
加载 glTF 2.0 和 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 | 在导入时翻转 V 纹理坐标(glTF 使用左上角原点;; True 转换为左下角) |
GltfSaveOptions
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,,写入自包含的二进制 GLB;当 False,,写入 JSON .gltf 使用外部缓冲区 |
flip_tex_coord_v | bool | True | 导出时翻转 V 纹理坐标 |
export_textures | bool | False | 将引用的纹理复制到输出包中(继承自 SaveOptions) |
StlLoadOptions
加载 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 | 在导入时翻转坐标系 |
scale | float | 1.0 | 对导入的几何体进行统一缩放 |
StlSaveOptions
STL 输出的保存选项。.
from aspose.threed.formats import StlSaveOptions
opts = StlSaveOptions()
opts.binary_mode = True
scene.save("output.stl", opts)flip_coordinate_system | bool | False | 在导出时翻转坐标系 |
scale | float | 1.0 | 对导出的几何体进行统一缩放 |
binary_mode | bool | False | 写入二进制 STL 而不是 ASCII STL |
FbxLoadOptions
加载 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 | 保留 FBX GlobalSettings 场景资产信息中的属性 |
compatible_mode | bool | False | 为来自旧版创作工具的 FBX 文件启用兼容模式 |
FbxSaveOptions
FBX 输出的保存选项。.
from aspose.threed.formats import FbxSaveOptions
opts = FbxSaveOptions()
opts.enable_compression = False
scene.save("output.fbx", opts)export_textures | bool | False | 将引用的纹理复制到输出目录 |
reuse_primitive_mesh | bool | False | 在输出中去除重复的相同网格几何体 |
enable_compression | bool | True | 启用二进制 FBX 内部压缩 |
fold_repeated_curve_data | None | 折叠相同的动画曲线段 | |
export_legacy_material_properties | bool | True | 包含旧版 Phong/Lambert 用于兼容性的材质属性节点 |
video_for_texture | bool | False | 在 FBX 视频节点中嵌入纹理数据 |
embed_textures | bool | False | 在 FBX 二进制文件中内嵌纹理文件 |
generate_vertex_element_material | bool | False | 添加一个 VertexElementMaterial 用于每多边形材质分配的图层 |
ColladaLoadOptions
加载 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 | 在导入时翻转坐标系 |
enable_materials | bool | True | 导入 COLLADA 材质定义 |
scale | float | 1.0 | 对导入的几何体进行统一缩放 |
normalize_normal | bool | True | 归一化导入的法线向量 |
ColladaSaveOptions
COLLADA 输出的保存选项。.
from aspose.threed.formats import ColladaSaveOptions
opts = ColladaSaveOptions()
opts.indented = False # compact output
scene.save("output.dae", opts)flip_coordinate_system | bool | False | 在导出时翻转坐标系 |
enable_materials | bool | True | 编写 COLLADA 材质定义 |
indented | bool | True | 对 XML 输出进行美化并添加缩进 |
ThreeMfLoadOptions / ThreeMfSaveOptions
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)这些类继承基属性自 LoadOptions / SaveOptions 分别。当前 FOSS 发行版中未记录任何额外的特定格式属性。.