Skip to main content

API Reference

All functions live in io_mesh_3mf.api. Import them directly:

from io_mesh_3mf.api import import_3mf, export_3mf, inspect_3mf

Version & Capabilities

API_VERSION = (1, 0, 0)
API_VERSION_STRING = ".".join(str(v) for v in API_VERSION)


API_CAPABILITIES = frozenset({
    "import",                 # import_3mf() available
    "export",                 # export_3mf() available
    "inspect",                # inspect_3mf() available
    "batch",                  # batch_import/batch_export available
    "callbacks",              # on_progress, on_warning, on_object_created
    "target_collection",      # import to specific collection
    "orca_format",            # Orca/BambuStudio export format
    "prusa_format",           # PrusaSlicer export format
    "paint_mode",             # MMU paint segmentation
    "project_template",       # Custom Orca project template
    "object_settings",        # Per-object Orca settings
    "building_blocks",        # colors, types, segmentation sub-namespaces
})

Result Dataclasses

ImportResult

FieldTypeDescription
statusstr"FINISHED" on success, "CANCELLED" on failure.
num_loadedintNumber of objects successfully imported.
objectsListList of bpy.types.Object instances created during import.
warningsList[str]Accumulated warning messages (if any).

ExportResult

FieldTypeDescription
statusstr"FINISHED" on success, "CANCELLED" on failure.
num_writtenintNumber of objects written to the archive.
filepathstrAbsolute path of the written .3mf file.
warningsList[str]Accumulated warning messages (if any).

InspectResult

FieldTypeDescription
statusstr"OK" on success, "ERROR" on failure.
error_messagestrHuman-readable error string when status == "ERROR".
unitstrThe unit declared in the model file ("millimeter" etc.).
metadataDict[str, str]Top-level <metadata> key/value pairs from the model.
objectsList[Dict]Per-object summary dicts with keys: - "id" — resource ID string - "name" — object name (or "" if unnamed) - "type" — object type attribute ("model" / "solidsupport" / …) - "num_vertices" — vertex count - "num_triangles" — triangle count - "num_components" — number of component references - "has_materials" — whether face materials are present - "has_segmentation" — whether MMU paint segmentation is present
materialsList[Dict]Per-material-group summary dicts with keys: - "id" — resource ID string - "type""basematerials" | "colorgroup" | "texture2dgroup" - "count" — number of entries in the group
texturesList[Dict]Per-texture summary dicts with keys: - "id" — resource ID string - "path" — internal archive path - "contenttype" — MIME type string
extensions_usedSet[str]Set of namespace URIs for extensions referenced in the model's requiredextensions / recommendedextensions.
vendor_formatOptional[str]Detected slicer vendor format ("orca" / None).
archive_filesList[str]List of all file paths inside the ZIP archive.
num_objectsintTotal number of <object> resources.
num_triangles_totalintSum of all triangle counts across objects.
num_vertices_totalintSum of all vertex counts across objects.
warningsList[str]Accumulated warnings during inspection.

import_3mf

def import_3mf(filepath: str,
    global_scale: float = 1.0,
    import_materials: str = 'MATERIALS',
    reuse_materials: bool = True,
    import_location: str = 'KEEP',
    origin_to_geometry: str = 'KEEP',
    grid_spacing: float = 0.1,
    auto_smooth: bool = False,
    auto_smooth_angle: float = 0.5236,
    paint_uv_method: str = 'SMART',
    paint_texture_size: int = 0,
    target_collection: str | None = None,
    on_progress: ProgressCallback | None = None,
    on_warning: WarningCallback | None = None,
    on_object_created: ObjectCreatedCallback | None = None,
) -> ImportResult

Import a 3MF file into the current Blender scene.

ParameterTypeDefaultDescription
filepathstrrequiredPath to the .3mf file to import.
global_scalefloat1.0Scale multiplier (default 1.0).
import_materialsstr'MATERIALS'"MATERIALS" | "PAINT" | "NONE".
reuse_materialsboolTrueReuse existing Blender materials by name/color.
import_locationstr'KEEP'"ORIGIN" | "CURSOR" | "KEEP" | "GRID".
origin_to_geometrystr'KEEP'"KEEP" | "CENTER" | "BOTTOM".
grid_spacingfloat0.1Spacing between objects in grid layout mode.
auto_smoothboolFalseApply Smooth by Angle modifier to imported objects.
auto_smooth_anglefloat0.5236Maximum angle (radians) for smooth shading (default 0.5236 = 30 degrees).
paint_uv_methodstr'SMART'"SMART" (default) or "LIGHTMAP". Smart UV groups adjacent faces; Lightmap gives each face unique space.
paint_texture_sizeint0Override texture resolution (0 = auto).
target_collectionstrNoneName of an existing Blender collection to place imported objects into. If None, objects are added to the active collection. If the named collection does not exist it will be created and linked to the scene.
on_progressProgressCallbackNoneOptional (percentage: int, message: str) callback.
on_warningWarningCallbackNoneOptional (message: str) callback fired for each warning.
on_object_createdObjectCreatedCallbackNoneOptional callback fired after each Blender object is built. Receives (blender_object, resource_id) arguments.

Returns: ImportResultImportResult with status, loaded count, and object list.

export_3mf

def export_3mf(filepath: str,
    objects = None,
    use_selection: bool = False,
    export_hidden: bool = False,
    skip_disabled: bool = True,
    global_scale: float = 1.0,
    use_mesh_modifiers: bool = True,
    coordinate_precision: int = 9,
    compression_level: int = 3,
    use_orca_format: str = 'AUTO',
    use_components: bool = True,
    mmu_slicer_format: str = 'ORCA',
    subdivision_depth: int = 7,
    thumbnail_mode: str = 'AUTO',
    thumbnail_resolution: int = 256,
    thumbnail_image: str = '',
    project_template: str | None = None,
    object_settings: Dict | None = None,
    on_progress: ProgressCallback | None = None,
    on_warning: WarningCallback | None = None,
) -> ExportResult

Export Blender objects to a 3MF file.

ParameterTypeDefaultDescription
filepathstrrequiredDestination path for the .3mf file.
objectsNoneExplicit list of bpy.types.Object to export. If None, falls back to use_selection logic or all scene objects.
use_selectionboolFalseExport selected objects only (ignored when objects is given).
export_hiddenboolFalseInclude hidden objects.
skip_disabledboolTrueSkip objects disabled for rendering (camera icon) and objects in excluded/hidden collections (default True).
global_scalefloat1.0Scale multiplier (default 1.0).
use_mesh_modifiersboolTrueApply modifiers before exporting.
coordinate_precisionint9Decimal precision for vertex coordinates.
compression_levelint3ZIP deflate compression level (0–9, default 3). 0 = no compression (fastest, largest), 9 = max compression (slowest, smallest). 3 balances speed and file size.
use_orca_formatstr'AUTO'"AUTO" | "STANDARD" | "PAINT". AUTO (default) detects materials and paint data, choosing the best exporter automatically. STANDARD always uses the spec-compliant StandardExporter with proper component instancing. PAINT forces segmentation export. When project_template or object_settings is provided, the Orca exporter is used automatically even in AUTO mode.
use_componentsboolTrueUse component instances for linked duplicates.
mmu_slicer_formatstr'ORCA'"ORCA" | "PRUSA" (only relevant when use_orca_format is "PAINT").
subdivision_depthint7Maximum recursive subdivision depth for paint segmentation (4–10, default 7). Higher = finer detail but slower.
thumbnail_modestr'AUTO'"AUTO" (render clean preview), "CUSTOM" (use thumbnail_image), or "NONE" (no thumbnail).
thumbnail_resolutionint256Width and height in pixels for AUTO mode (default 256).
thumbnail_imagestr''Absolute path to an image file for CUSTOM mode.
project_templatestrNoneAbsolute path to a JSON file to use as the Orca project_settings.config instead of the built-in template. The addon loads this file, patches filament_colour and resizes filament arrays to match the export, then writes it to the archive. If the file does not exist or is invalid JSON, a warning is logged and the built-in template is used as a fallback. Only relevant for Orca/BambuStudio exports (mmu_slicer_format="ORCA").
object_settingsDictNonePer-object Orca Slicer setting overrides. A dict mapping bpy.types.Object instances to dicts of {setting_key: value_string} pairs. These are written as <metadata> entries in model_settings.config so that Orca applies different print settings to individual objects. Keys are passed through without validation — any valid Orca setting key (e.g. "layer_height", "wall_loops", "sparse_infill_speed") is accepted. Objects not present in this dict use project defaults. Example:: object_settings={ supports_obj: { "layer_height": "0.12", "wall_loops": "2", "sparse_infill_speed": "50", }, # other objects use project defaults }
on_progressProgressCallbackNoneOptional (percentage: int, message: str) callback.
on_warningWarningCallbackNoneOptional (message: str) callback for warnings.

Returns: ExportResultExportResult with status, written count, and filepath.

inspect_3mf

def inspect_3mf(filepath: str,
) -> InspectResult

Inspect a 3MF file without importing anything into Blender.

ParameterTypeDescription
filepathstrPath to the .3mf file.

Returns: InspectResultInspectResult with archive metadata and statistics.

batch_import

def batch_import(filepaths: Sequence[str],
    on_progress: ProgressCallback | None = None,
    on_warning: WarningCallback | None = None,
    on_object_created: ObjectCreatedCallback | None = None,
    **import_kwargs,
) -> List[ImportResult]

Import multiple 3MF files in sequence with per-file error isolation.

ParameterTypeDefaultDescription
filepathsSequence[str]requiredSequence of .3mf file paths to import.
on_progressProgressCallbackNoneOptional global progress callback. Receives (percentage, message) where percentage spans 0-100 across all files.
on_warningWarningCallbackNoneWarning callback forwarded to each import_3mf call.
on_object_createdObjectCreatedCallbackNoneObject-created callback forwarded to each call.
**import_kwargsKeyword arguments forwarded to import_3mf.

Returns: List[ImportResult] — List of ImportResult, one per input file (same order).

batch_export

def batch_export(items: Sequence[Tuple[str, List]] | None,
    on_progress: ProgressCallback | None = None,
    on_warning: WarningCallback | None = None,
    **export_kwargs,
) -> List[ExportResult]

Export multiple 3MF files in sequence with per-file error isolation.

ParameterTypeDefaultDescription
itemsSequence[Tuple[str, ListrequiredSequence of (filepath, objects_or_None) tuples.
on_progressProgressCallbackNoneOptional global progress callback.
on_warningWarningCallbackNoneWarning callback forwarded to each export_3mf call.
**export_kwargsKeyword arguments forwarded to export_3mf.

Returns: List[ExportResult] — List of ExportResult, one per item (same order).

Callback Types

TypeSignatureDescription
ProgressCallback(int, str) -> None(percentage 0-100, message)
WarningCallback(str,) -> None(warning_message)
ObjectCreatedCallback(Any, str) -> None(blender_object, resource_id)