FileFormat — Aspose.3D FOSS for Python API Reference
Example
FileFormat يعمل كواصف للصيغة وكذلك كسجل لجميع صيغ ملفات 3D المدعومة. كل صيغة ممثلة كـ FileFormat كائن يمكن الوصول إليه كخاصية للصف أو عبر طرق إنشاء ثابتة. تقوم بتمرير FileFormat الكائنات إلى Scene.save() لإجبار صيغة محددة، أو استخدم FileFormat.detect() لتحديد صيغة ملف غير معروف.
Example: aspose.threed
from aspose.threed import FileFormatثوابت الصيغ المدعومة
ثوابت الصيغة التي يتم دعمها بنشاط (المستوردين و/أو المصدرين المسجلين) في إصدار FOSS موضحة أدناه. الثوابت المذكورة كـ None في المصدر هي أسماء محجوزة لصيغ لم تُنفذ بعد.
مدعومة بنشاط (إصدار FOSS)
| Example | Example | Example |
|---|---|---|
FileFormat.WAVEFRONT_OBJ() | .obj | طريقة ثابتة تُعيد ObjFormat كائن |
FileFormat.GLTF2() | .gltf / .glb | glTF 2.0; طريقة ثابتة تُعيد GltfFormat مثيل |
FileFormat.FBX7400ASCII() | .fbx | FBX 7.4 ASCII; طريقة ثابتة |
FileFormat.MICROSOFT_3MF | .3mf | 3MF (set at module load) |
FileFormat.COLLADA | .dae | Example |
FileFormat.STL_BINARY | .stl | STL ثنائي (يُضبط عند تحميل الوحدة) |
FileFormat.STLASCII | .stl | STL ASCII |
Example
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.
الطرق الثابتة
| Example | نوع الإرجاع | Example |
|---|---|---|
FileFormat.detect(stream, file_name) | `FileFormat | None` |
FileFormat.get_format_by_extension(ext) | `FileFormat | None` |
خصائص الكائن
| Example | Example | Example |
|---|---|---|
extension | str | الامتداد الأساسي للملف (بدون النقطة الأولية) |
extensions | list[str] | جميع الامتدادات المدعومة من هذا التنسيق |
content_type | str | سلسلة نوع MIME |
can_export | bool | ما إذا كان تصدير إلى هذا التنسيق مدعومًا |
can_import | bool | ما إذا كان استيراد من هذا التنسيق مدعومًا |
version | str | سلسلة إصدار التنسيق |
طرق الكائن
| Example | نوع الإرجاع | Example |
|---|---|---|
create_load_options() | LoadOptions | ينشئ المناسب الخاص بالتنسيق LoadOptions فئة فرعية |
create_save_options() | SaveOptions | ينشئ المناسب الخاص بالتنسيق 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__)