FileFormat — Aspose.3D FOSS for Python API Reference
Example
FileFormat dient zowel als een formatbeschrijving als een register van alle ondersteunde 3D‑bestandsformaten. Elk format wordt weergegeven als een FileFormat instance die toegankelijk is als een klasse‑attribuut of via statische fabrieksmethoden. Je geeft FileFormat instances aan Scene.save() om een specifiek format af te dwingen, of gebruik FileFormat.detect() om het format van een onbekend bestand te identificeren.
Example: aspose.threed
from aspose.threed import FileFormatOndersteunde formatconstanten
Format‑constanten die actief worden ondersteund (importeurs en/of exporteurs geregistreerd) in de FOSS‑release worden hieronder getoond. Constanten die vermeld staan als None in de bron zijn gereserveerde namen voor formaten die nog niet geïmplementeerd zijn.
Actief ondersteund (FOSS‑release)
| Example | Example | Example |
|---|---|---|
FileFormat.WAVEFRONT_OBJ() | .obj | Statische methode die een ObjFormat instance |
FileFormat.GLTF2() | .gltf / .glb | glTF 2.0; statische methode die een GltfFormat instance |
FileFormat.FBX7400ASCII() | .fbx | FBX 7.4 ASCII; statische methode |
FileFormat.MICROSOFT_3MF | .3mf | 3MF (set at module load) |
FileFormat.COLLADA | .dae | Example |
FileFormat.STL_BINARY | .stl | STL binair (ingesteld bij het laden van de module) |
FileFormat.STLASCII | .stl | STL ASCII |
Example
FBX‑versies 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.
Statische methoden
| Example | Returntype | Example |
|---|---|---|
FileFormat.detect(stream, file_name) | `FileFormat | None` |
FileFormat.get_format_by_extension(ext) | `FileFormat | None` |
Instantie‑eigenschappen
| Example | Example | Example |
|---|---|---|
extension | str | Primaire bestandsextensie (zonder voorvoegende punt) |
extensions | list[str] | Alle extensies die door dit formaat worden ondersteund |
content_type | str | MIME-type string |
can_export | bool | Of exporteren naar dit formaat wordt ondersteund |
can_import | bool | Of importeren vanuit dit formaat wordt ondersteund |
version | str | Formaatversie string |
Instantiemethoden
| Example | Retourtype | Example |
|---|---|---|
create_load_options() | LoadOptions | Maakt de juiste formaat-specifieke LoadOptions subklasse |
create_save_options() | SaveOptions | Maakt de juiste formaat-specifieke SaveOptions subklasse |
Example
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__)