FileFormat — Aspose.3D FOSS for Python API Reference

Overview

FileFormat serves as both a format descriptor and a registry of all supported 3D file formats. Each format is represented as a FileFormat instance accessible as a class attribute or via static factory methods. You pass FileFormat instances to Scene.save() to force a specific format, or use FileFormat.detect() to identify an unknown file’s format.

Package: aspose.threed

from aspose.threed import FileFormat

Supported Format Constants

Format constants that are actively supported (importers and/or exporters registered) in the FOSS release are shown below. Constants listed as None in the source are reserved names for formats not yet implemented.

Actively Supported (FOSS release)

AttributeExtensionNotes
FileFormat.WAVEFRONT_OBJ().objStatic method returning an ObjFormat instance
FileFormat.GLTF2().gltf / .glbglTF 2.0; static method returning a GltfFormat instance
FileFormat.FBX7400ASCII().fbxFBX 7.4 ASCII; static method
FileFormat.MICROSOFT_3MF_FORMAT().3mf3MF; static method
FileFormat.COLLADA.daeCOLLADA (set at module load via plugin)
FileFormat.STL_BINARY.stlSTL binary (set at module load)
FileFormat.STLASCII.stlSTL ASCII

Reserved (not yet implemented)

FBX versions 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.

Static Methods

MethodReturn TypeDescription
FileFormat.detect(stream, file_name)FileFormat | NoneDetects the format from a file stream; file_name is used as a hint
FileFormat.get_format_by_extension(ext)FileFormat | NoneReturns the format matching an extension string such as ".obj", ".glb", ".fbx", ".dae", ".3mf", ".stl"

Instance Properties

NameTypeDescription
extensionstrPrimary file extension (without leading dot)
extensionslist[str]All extensions supported by this format
content_typestrMIME type string
can_exportboolWhether exporting to this format is supported
can_importboolWhether importing from this format is supported
versionstrFormat version string

Instance Methods

MethodReturn TypeDescription
create_load_options()LoadOptionsCreates the appropriate format-specific LoadOptions subclass
create_save_options()SaveOptionsCreates the appropriate format-specific SaveOptions subclass

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

See Also