FileFormat

Methods

FileFormat ทำหน้าที่เป็นทั้งตัวบรรยายรูปแบบและทะเบียนของรูปแบบไฟล์ 3D ที่รองรับทั้งหมด แต่ละรูปแบบจะถูกแทนด้วย FileFormat อินสแตนซ์ที่เข้าถึงได้เป็นแอตทริบิวต์ของคลาสหรือผ่านเมธอดแฟกทอรีแบบสเตติก คุณส่ง FileFormat อินสแตนซ์ไปยัง Scene.save() เพื่อบังคับรูปแบบเฉพาะ หรือใช้ FileFormat.detect() เพื่อระบุรูปแบบของไฟล์ที่ไม่ทราบ.

Methods: aspose.threed

from aspose.threed import FileFormat

คอนสแตนท์รูปแบบที่รองรับ

ค่าคงที่ของรูปแบบที่ได้รับการสนับสนุนอย่างแข็งขัน (ผู้นำเข้าและ/หรือผู้ส่งออกที่ลงทะเบียน) ในรุ่น FOSS แสดงด้านล่าง ค่าคงที่ที่ระบุเป็น None ในซอร์สมีชื่อที่สงวนไว้สำหรับฟอร์แมตที่ยังไม่ได้ทำการใช้งาน.

ที่รองรับอย่างเต็มที่ (รุ่น FOSS)

MethodsMethodsMethods
FileFormat.WAVEFRONT_OBJ().objเมธอดสแตติกที่คืนค่าเป็น ObjFormat อินสแตนซ์
FileFormat.GLTF2().gltf / .glbglTF 2.0; เมธอดสแตติกที่คืนค่าเป็น GltfFormat อินสแตนซ์
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; เมธอดสแตติก
FileFormat.MICROSOFT_3MF.3mf3MF (set at module load)
FileFormat.COLLADA.daeMethods
FileFormat.STL_BINARY.stlSTL binary (ตั้งค่าเมื่อโหลดโมดูล)
FileFormat.STLASCII.stlSTL ASCII

Methods

FBX เวอร์ชัน 6100–7700 (binary), Maya ASCII/Binary, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binary, PDF, Blender, DXF, PLY, X (binary/text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binary.

เมธอดสแตติก

Methodsชนิดผลลัพธ์Methods
FileFormat.detect(stream, file_name)`FileFormatNone`
FileFormat.get_format_by_extension(ext)`FileFormatNone`

คุณสมบัติของอินสแตนซ์

MethodsMethodsMethods
extensionstrส่วนขยายไฟล์หลัก (โดยไม่มีจุดนำหน้า)
extensionslist[str]ส่วนขยายทั้งหมดที่รองรับโดยรูปแบบนี้
content_typestrสตริงประเภท MIME
can_exportboolว่าการส่งออกเป็นรูปแบบนี้ได้รับการสนับสนุนหรือไม่
can_importboolว่าการนำเข้าจากรูปแบบนี้ได้รับการสนับสนุนหรือไม่
versionstrสตริงเวอร์ชันของรูปแบบ

เมธอดอินสแตนซ์

Methodsประเภทการคืนค่าMethods
create_load_options()LoadOptionsสร้างรูปแบบที่เหมาะสมตามฟอร์แมต LoadOptions คลาสย่อย
create_save_options()SaveOptionsสร้างรูปแบบที่เหมาะสมตามฟอร์แมต SaveOptions คลาสย่อย

Methods

from aspose.threed import Scene, FileFormat

# Auto-detect and load
scene = Scene.from_file("model.obj")

# Save with explicit format (force GLB binary)
from aspose.threed.formats import GltfSaveOptions
opts = GltfSaveOptions()
opts.binary_mode = True
scene.save("output.glb", opts)

# Get format by extension
fmt = FileFormat.get_format_by_extension(".fbx")
if fmt:
    print(fmt.can_import)   # True
    print(fmt.can_export)   # True

# Create options from a format instance
fmt_obj = FileFormat.get_format_by_extension(".obj")
load_opts = fmt_obj.create_load_options()   # ObjLoadOptions
save_opts = fmt_obj.create_save_options()   # ObjSaveOptions

# Detect format from file stream
with open("unknown_file.bin", "rb") as f:
    detected = FileFormat.detect(f, "unknown_file.bin")
    if detected:
        print(type(detected).__name__)

ดูเพิ่มเติม

 ภาษาไทย