FileFormat — Aspose.3D FOSS for Python API Reference
Example
FileFormat služi i kao opis formata i kao registar svih podržanih 3D formata datoteka. Svaki format je predstavljen kao FileFormat instanca dostupna kao atribut klase ili putem statičkih fabričkih metoda. Prosljeđujete FileFormat instance u Scene.save() da forsirate određeni format, ili koristite FileFormat.detect() da identifikujete format nepoznate datoteke.
Example: aspose.threed
from aspose.threed import FileFormatPodržane konstante formata
Konstante formata koje su aktivno podržane (uvoznici i/ili izvoznici registrovani) u FOSS izdanju su prikazane ispod. Konstantе navedene kao None u izvoru su rezervisana imena za formate koji još nisu implementirani.
Aktivno podržani (FOSS izdanje)
| Example | Example | Example |
|---|---|---|
FileFormat.WAVEFRONT_OBJ() | .obj | Statička metoda koja vraća ObjFormat instanca |
FileFormat.GLTF2() | .gltf / .glb | glTF 2.0; statička metoda koja vraća GltfFormat instanca |
FileFormat.FBX7400ASCII() | .fbx | FBX 7.4 ASCII; statička metoda |
FileFormat.MICROSOFT_3MF | .3mf | 3MF (set at module load) |
FileFormat.COLLADA | .dae | Example |
FileFormat.STL_BINARY | .stl | STL binarni (postavljeno pri učitavanju modula) |
FileFormat.STLASCII | .stl | STL ASCII |
Example
FBX verzije 6100–7700 (binarni), Maya ASCII/Binarni, Discreet 3DS, Universal 3D, GLTF 1.0, GLTF binarni, PDF, Blender, DXF, PLY, X (binarni/tekst), Draco, RVM, ASE, IFC, Siemens JT, AMF, VRML, HTML5, ZIP, USD/USDA/USDZ, XYZ, PCD, PCD binarni.
Статичке методе
| Example | Tip povratka | Example |
|---|---|---|
FileFormat.detect(stream, file_name) | `FileFormat | None` |
FileFormat.get_format_by_extension(ext) | `FileFormat | None` |
Svojstva instance
| Example | Example | Example |
|---|---|---|
extension | str | Primarna ekstenzija datoteke (bez početne tačke) |
extensions | list[str] | Sve ekstenzije koje podržava ovaj format |
content_type | str | String MIME tipa |
can_export | bool | Da li je izvoz u ovaj format podržan |
can_import | bool | Da li je uvoz iz ovog formata podržan |
version | str | String verzije formata |
Metode instance
| Example | Tip povratne vrednosti | Example |
|---|---|---|
create_load_options() | LoadOptions | Kreira odgovarajući format‑specifičan LoadOptions podklasu |
create_save_options() | SaveOptions | Kreira odgovarajući format‑specifičan SaveOptions podklasu |
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__)