Load and Save Options

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

การดำเนินการนำเข้าและส่งออกทั้งหมดรับอ็อบเจ็กต์ options ทางเลือกที่สืบทอดมาจาก 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`FileFormatNone`
encoding`strNone`
file_system`FileSystemNone`
lookup_pathslist[str]ไดเรกทอรีเพิ่มเติมเพื่อค้นหาเมื่อแก้ไขการอ้างอิงภายนอก
file_name`strNone`

LoadOptions

คลาสฐานสำหรับอ็อบเจ็กต์ตัวเลือกการโหลดทั้งหมด.

คุณสมบัติเพิ่มเติม (นอกเหนือจาก IOConfig):

encoding`strNone`

SaveOptions

คลาสฐานสำหรับอ็อบเจ็กต์ตัวเลือกการบันทึกทั้งหมด.

คุณสมบัติเพิ่มเติม (นอกเหนือจาก IOConfig):

export_texturesbool
True, texture ที่อ้างอิงโดยฉากจะถูกคัดลอกไปยังผลลัพธ์ ค่าเริ่มต้นคือ 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 ไฟล์ material
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ส่งออก vertices เท่านั้น (ไม่มี polygon faces)
verboseboolFalseรวมคอมเมนต์ OBJ เพิ่มเติมในผลลัพธ์
serialize_wboolFalseเขียนส่วนประกอบ W ของ control points
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 แบบไบนารีแทน STL แบบ ASCII

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 ปัจจุบัน.


ดูเพิ่มเติม

 ภาษาไทย