FileFormat

Methods

FileFormat dient sowohl als Formatbeschreiber als auch als Register aller unterstützten 3D-Dateiformate. Jedes Format wird als ein FileFormat Instanz, die als Klassenattribut oder über statische Fabrikmethoden zugänglich ist. Sie übergeben FileFormat Instanzen an Scene.save() um ein bestimmtes Format zu erzwingen, oder verwenden FileFormat.detect() um das Format einer unbekannten Datei zu ermitteln.

Methods: aspose.threed

from aspose.threed import FileFormat

Unterstützte Formatkonstanten

Formatkonstanten, die im FOSS-Release aktiv unterstützt werden (Importeure und/oder Exporteure registriert), sind unten aufgeführt. Als Konstanten, die im Quellcode als None im Quellcode erscheinen, sind reservierte Namen für noch nicht implementierte Formate.

Aktiv unterstützt (FOSS‑Version)

MethodsMethodsMethods
FileFormat.WAVEFRONT_OBJ().objStatische Methode, die ein ObjFormat Instanz
FileFormat.GLTF2().gltf / .glbglTF 2.0; statische Methode, die ein GltfFormat Instanz
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; statische Methode
FileFormat.MICROSOFT_3MF.3mf3MF (set at module load)
FileFormat.COLLADA.daeMethods
FileFormat.STL_BINARY.stlSTL binary (bei Modul-Ladung festgelegt)
FileFormat.STLASCII.stlSTL ASCII

Methods

FBX‑Versionen 6100–7700 (binär), Maya ASCII/Binär, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binär, PDF, Blender, DXF, PLY, X (binär/Text), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binär.

Statische Methoden

MethodsRückgabetypMethods
FileFormat.detect(stream, file_name)`FileFormatNone`
FileFormat.get_format_by_extension(ext)`FileFormatNone`

Instanz‑Eigenschaften

MethodsMethodsMethods
extensionstrPrimäre Dateierweiterung (ohne führenden Punkt)
extensionslist[str]Alle von diesem Format unterstützten Erweiterungen
content_typestrMIME‑Typ‑Zeichenkette
can_exportboolOb das Exportieren in dieses Format unterstützt wird
can_importboolOb das Importieren aus diesem Format unterstützt wird
versionstrFormatversionszeichenkette

Instanzmethoden

MethodsRückgabetypMethods
create_load_options()LoadOptionsErzeugt das passende format-spezifische LoadOptions Unterklasse
create_save_options()SaveOptionsErzeugt das passende format-spezifische SaveOptions Unterklasse

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

Siehe auch

 Deutsch