Load and Save Options

Load and Save Options — Aspose.3D FOSS for Python API Reference

所有导入和导出操作接受一个可选的、派生自 LoadOptionsSaveOptions.。将适当的子类传递给 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,
)

LoadOptionsSaveOptions 继承自 IOConfig. 以下属性在每个 options 对象上均可用。.

file_format`FileFormatNone`
encoding`strNone`
file_system`FileSystemNone`
lookup_pathslist[str]解析外部引用时要搜索的额外目录
file_name`strNone`

LoadOptions

所有加载选项对象的基类。.

附加属性 (超出 IOConfig):

encoding`strNone`

SaveOptions

所有保存选项对象的基类。.

附加属性 (超出 IOConfig):

export_texturesbool
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_systemboolFalse导入时翻转坐标系
enable_materialsboolTrue加载随附的 .mtl 材质文件
scalefloat1.0对所有导入的几何体应用统一缩放
normalize_normalboolTrue将导入的法向量归一化为单位长度

ObjSaveOptions

Wavefront OBJ 文件的保存选项。.

from aspose.threed.formats import ObjSaveOptions
opts = ObjSaveOptions()
opts.enable_materials = False
scene.save("output.obj", opts)
apply_unit_scaleboolFalse将场景的单位缩放因子应用于导出的坐标
point_cloudboolFalse仅导出顶点(不包括多边形面)
verboseboolFalse在输出中包含额外的 OBJ 注释
serialize_wboolFalse写入控制点的 W 分量
enable_materialsboolTrue写入 a .mtl material 文件并从中引用它 .obj
flip_coordinate_systemboolFalse在导出时翻转坐标系
axis_system`AxisSystemNone`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_vboolTrue在导入时翻转 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_modeboolFalse
True,,写入自包含的二进制 GLB;当 False,,写入 JSON .gltf 使用外部缓冲区
flip_tex_coord_vboolTrue导出时翻转 V 纹理坐标
export_texturesboolFalse将引用的纹理复制到输出包中(继承自 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_systemboolFalse在导入时翻转坐标系
scalefloat1.0对导入的几何体进行统一缩放

StlSaveOptions

STL 输出的保存选项。.

from aspose.threed.formats import StlSaveOptions
opts = StlSaveOptions()
opts.binary_mode = True
scene.save("output.stl", opts)
flip_coordinate_systemboolFalse在导出时翻转坐标系
scalefloat1.0对导出的几何体进行统一缩放
binary_modeboolFalse写入二进制 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_settingsboolFalse保留 FBX GlobalSettings 场景资产信息中的属性
compatible_modeboolFalse为来自旧版创作工具的 FBX 文件启用兼容模式

FbxSaveOptions

FBX 输出的保存选项。.

from aspose.threed.formats import FbxSaveOptions
opts = FbxSaveOptions()
opts.enable_compression = False
scene.save("output.fbx", opts)
export_texturesboolFalse将引用的纹理复制到输出目录
reuse_primitive_meshboolFalse在输出中去除重复的相同网格几何体
enable_compressionboolTrue启用二进制 FBX 内部压缩
fold_repeated_curve_data
None折叠相同的动画曲线段
export_legacy_material_propertiesboolTrue包含旧版 Phong/Lambert 用于兼容性的材质属性节点
video_for_textureboolFalse在 FBX 视频节点中嵌入纹理数据
embed_texturesboolFalse在 FBX 二进制文件中内嵌纹理文件
generate_vertex_element_materialboolFalse添加一个 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_systemboolFalse在导入时翻转坐标系
enable_materialsboolTrue导入 COLLADA 材质定义
scalefloat1.0对导入的几何体进行统一缩放
normalize_normalboolTrue归一化导入的法线向量

ColladaSaveOptions

COLLADA 输出的保存选项。.

from aspose.threed.formats import ColladaSaveOptions
opts = ColladaSaveOptions()
opts.indented = False   # compact output
scene.save("output.dae", opts)
flip_coordinate_systemboolFalse在导出时翻转坐标系
enable_materialsboolTrue编写 COLLADA 材质定义
indentedboolTrue对 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 发行版中未记录任何额外的特定格式属性。.


另见

 中文