Skip to content

Maintained Fork (4.2+)|| Now on the Blender Extensions Platform || Now with full Paint Support for Orca/Bambu and Prusa/Super || Issues/Feature Requests Welcome#86

Open
Clonephaze wants to merge 117 commits intoGhostkeeper:masterfrom
Clonephaze:master
Open

Maintained Fork (4.2+)|| Now on the Blender Extensions Platform || Now with full Paint Support for Orca/Bambu and Prusa/Super || Issues/Feature Requests Welcome#86
Clonephaze wants to merge 117 commits intoGhostkeeper:masterfrom
Clonephaze:master

Conversation

@Clonephaze
Copy link
Copy Markdown

@Clonephaze Clonephaze commented Oct 8, 2025

Important

The fork found here is incompatible with Ghostkeepers Original work. A slew of new features have been added, including a full re-write of the api intended for those using/creating scripts. This PR is informational only

Download Here
Official Blender Extensions Platform – Includes automatic updates!

New Features!

TL;DR:

  • Actively maintained continuation of the original (abandoned at v1.0.2)
  • Slicer support: Orca, Bambu Studio, PrusaSlicer, SuperSlicer (round-trip safe)
  • Per-triangle MMU / color data preserved and editable in Blender
  • Proper PBR materials + texture support
  • Production-grade 3MF import/export (components, instances, metadata)
  • Built-in multi-filament painting tools with ability to bake procedural textures to paint data
  • Public Python API + modern Blender (4.2+/5.0) support

MMU painting

  • Built-in multi-filament paint panel
  • Create, add, remove, and manage filament sets
  • Paint per-triangle assignments using Blender tools
  • Automatic UI switching on import
  • Fast NumPy-accelerated operations

Segmentation encoding

  • Slicer-agnostic multi-material encoding
  • Recursive subdivision stored as hex strings
  • Lossless UV texture ↔ segmentation round-trip

Slicer support

  • Orca Slicer, Bambu Studio, PrusaSlicer, and SuperSlicer import/export
  • Per-triangle color zones or MMU segmentation preserved
  • Automatic slicer/vendor format detection on import
  • Filament colors survive round-trip
  • Orca filament metadata generated when needed

Materials and Properties Extension

  • PBR material workflows: metallic, specular, translucent
  • Support for roughness, glossiness, IOR, attenuation
  • Texture-based materials (color, roughness, metallic, specular, etc.)
  • Automatic texture extraction from 3MF
  • Reuse existing Blender materials on import

Production Extension

  • Multi-file object layouts (3D/Objects/*.model)
  • Component references via UUID/path
  • Proper OPC relationship files
  • Linked duplicates export as shared components
  • Smaller files, restored instances on import

Triangle Sets Extension

  • Full <triangleset> import/export
  • Per-face integer attributes (Blender 4.x+)
  • Optimized range encoding for consecutive triangles

Import workflow

  • Drag-and-drop .3mf into the viewport
  • Placement options (original, origin, 3D cursor)
  • Origin control (original, center, bottom-center)
  • Optional grid layout for multiple objects
  • Geometry-only import option
  • Quick options popup on drag-drop

Export workflow

  • Embedded viewport thumbnail (256×256)
  • Non-manifold geometry warnings
  • “Selection Only” validation
  • Optional export of hidden objects
  • Configurable coordinate precision
  • Object names written to 3MF metadata

Public API

  • Headless import/export functions
  • Archive inspection without creating objects
  • Batch import/export with per-file isolation
  • Progress, warning, and object callbacks
  • Reusable internal modules exposed

Extensions & standards

  • Pluggable 3MF extension system
  • Required vs optional extension handling
  • XML namespace resolution utilities
  • 3MF Core Spec v1.4.0 compliant

Robustness & quality

  • Full Unicode support (CJK, RTL, emoji)
  • Safe handling of Blender string lifetimes
  • Correct sRGB ↔ linear color conversions
  • Blender 4.2+ / 5.0 support
  • Addon preferences panel
  • 334 real Blender tests (unit + integration, no mocking)
  • Modular, refactored architecture

Clonephaze and others added 30 commits October 7, 2025 03:55
Refactored codebase for compatibility with Blender 4.2+, including import and export modules, annotations, constants, and metadata handling. Updated README with modernization notice, credits, and installation guidance. Improved reload logic, imports, and property annotation syntax. Added copyright for modernization work and enhanced code style consistency.
Deleted obsolete __init__ methods from Export3MF and Import3MF classes to streamline initialization. Added blender_manifest.toml for Blender 4.2+ compatibility and removed bl_info from __init__.py, transitioning metadata to the manifest file.
Major Issues Fixed -- Now works in 4.2+
Introduces integration tests for the Blender 3MF addon, including cross-platform runner scripts and documentation in test/README.md. Updates unit tests to use explicit imports, improves test initialization, and revises CI workflow to Python 3.11. Modernization checklist updated to reflect major milestone and test progress.
Updates documentation and test scripts for full compatibility with Blender 4.2+ and Python 3.11+. Adds multi-version integration test support, improves installation instructions, and documents comprehensive test coverage (142 unit tests, 16 integration tests). Modernization status and checklist are updated to reflect production readiness and CI/CD integration.
All major functions and methods in the 3MF addon have been annotated with type hints for improved code quality and IDE support. Updates include changes to __init__.py, annotations.py, constants.py, export_3mf.py, import_3mf.py, metadata.py, and unit_conversions.py. MODERNIZATION_CHECKLIST.md updated to reflect completion of type hinting and changelog for v1.1.0; manifest version bumped to 1.1.0.
Added __all__ definitions to all modules for improved IDE and documentation support. Replaced string concatenations with f-strings and updated error reporting to use self.report() for user feedback in export_3mf.py and import_3mf.py. Updated outdated comments and marked modernization checklist as complete for quality phase.
Introduces a safe_report method to both Export3MF and Import3MF classes to handle reporting messages in a way compatible with both Blender's operator system and unit tests. All direct calls to self.report are replaced with safe_report to improve robustness and testability.
Added W503 to the ignored pycodestyle errors in the test workflow to resolve conflicts with PEP8's recommendation to break before binary operators.
Corrected whitespace, indentation, and line breaks in export_3mf.py, import_3mf.py, and run_integration_tests.py for improved code readability and consistency. No functional changes were made.
Test Fixes, Integration Suite, Code Quality Enhancements, Doc Updates
Expanded and reorganized CHANGES.md to provide clearer feature, technical, and testing breakdowns for the Blender 3MF addon modernization. Deleted MODERNIZATION_CHECKLIST.md as the checklist is no longer needed after completion of modernization tasks.
Added checks to skip empty material slots when exporting 3MF files. This prevents errors when objects or triangles reference material slots without assigned materials. Fixes issue #4
Introduces a new 'tests/' directory with integration tests using the real Blender API, covering export, import, materials, archive structure, and edge cases. Includes test utilities, resources, and a test runner script. Updates legacy test README to clarify the distinction between legacy unit tests and new integration tests. Also fixes a line length error in `export_3mf.py`
Added BOM to the start of several Python files and normalized whitespace in io_mesh_3mf/export_3mf.py and all test files. This improves consistency and prevents issues with encoding or formatting in environments sensitive to BOM and whitespace.
Support non-standard scene scale / unit combinations. In particular,
make sure the common scale=0.001 and unit=MILLIMETER combination is
supported. In that case, blender units equal millimeters, and no scale
changes are required for the scene on either import or export.
Make sub-objects more readable by setting the object name attribute.
This makes them show up using the assigned name rather than the
numerical IDs in applications like PrusaSlicer.
Handle per-object name attributes in the import path, giving precedence
to the lowest level `Title` metadata or `name` attribute. Tested with
exports from previous export path patch (round tripping), as well as
prusa and 3mf reference objects.
Per subject. Still default to exporting visible objects only.
Float to decimal string conversion is a very hot export path. The
format_number method previously tried to reduce the file size by
stripping trailing zeroes and optional decimal point. In practice, I
found this neither helped export times, nor exported file size after
compression.

In a moderately complex test file, I found the simpler method reduces
compressed file size from 4mb to 3.6mb, and export time from about 9s to
8s.
Default to preserving 9 decimal places, which is lossless for 32 bit
floats used in blender vertex coordinates. This avoids creating
non-manifold edges / vertices in fine structures due to rounding errors.
Better to have a safe / lossless default, while letting users reduce
resolution for structures where full resolution is not needed. In my
testing, the performance impact of full resolution is relatively minor,
roughly canceling out what was gained with simplified / regularized
number printing in the earlier diff.
Introduced standardized issue templates for bug reports and feature requests in the .github/ISSUE_TEMPLATE directory to streamline issue submission and improve project maintainability.
Introduces ThreeMFPreferences for user-configurable defaults in the 3MF addon, including coordinate precision, export hidden objects, apply modifiers, and global scale. Updates import and export operators to initialize properties from preferences. Adjusts unit scaling logic and test cases to match new behavior and formatting, and improves test robustness for floating point comparisons.
Refactored string formatting for property descriptions and test assertions to improve readability. Adjusted indentation in import_3mf.py for consistency. No functional changes were made.
Introduces a new preferences panel for the 3MF addon, allowing users to configure default coordinate precision, export of hidden objects, modifier application, and global scale. Enhances export functionality to notify users when hidden objects are skipped and adds comprehensive unit tests for preferences and hidden object export behavior. Updates documentation and test suite to reflect these new features and options.
Implements defensive string caching throughout the 3MF add-on to protect Unicode characters from Python's garbage collector, ensuring correct handling of non-ASCII characters in object names, material names, metadata, and file paths. Updates export and import logic to explicitly cache and convert strings, and adds a new Unicode test suite with 20+ tests for various scripts, emoji, and edge cases. Existing tests are updated for Unicode compatibility, and documentation is revised to reflect expanded Unicode support.
Add integration tests covering thumbnail generation for 3MF exports (tests/integration/test_thumbnail.py). These exercise AUTO/CUSTOM/NONE modes via both the Blender operator and the public API, verify presence and validity of Metadata/thumbnail.png in the archive, background-mode behavior, custom images from bpy.data.images and disk paths, and resolution handling. Also add unit tests for ExportOptions and ExportContext defaults and field passthrough (tests/unit/test_export_context.py). These tests improve coverage around thumbnail handling and export configuration defaults.
* Add metadata panel, presets, and paint refactor

Introduce 2.2.0 changes: add a 3MF Metadata sidebar panel and UI for editing standard/custom metadata; add export presets (Blender preset menu + operator) and a Compression slider (prefs + operator + API) to control ZIP deflate level. Preserve slicer config files on import by stashing them in Blender text blocks (stash_slicer_configs / get_stashed_config) and round-trip them on export (Orca/Prusa exporters use stashed configs when available). Refactor the MMU paint subsystem by splitting the large paint/panel.py into focused modules (helpers, properties, color_detection, operators, mmu_panel), centralize paint registration, and update bake/import/export code to use the new helpers. Misc: add panels package and registration, bump addon version to 2.2.0, update roadmap/changelog to reflect features and architecture changes.

* Update ROADMAP.md

* Delete NewDirectory.md

* pep 8
* Add metadata panel, presets, and paint refactor

Introduce 2.2.0 changes: add a 3MF Metadata sidebar panel and UI for editing standard/custom metadata; add export presets (Blender preset menu + operator) and a Compression slider (prefs + operator + API) to control ZIP deflate level. Preserve slicer config files on import by stashing them in Blender text blocks (stash_slicer_configs / get_stashed_config) and round-trip them on export (Orca/Prusa exporters use stashed configs when available). Refactor the MMU paint subsystem by splitting the large paint/panel.py into focused modules (helpers, properties, color_detection, operators, mmu_panel), centralize paint registration, and update bake/import/export code to use the new helpers. Misc: add panels package and registration, bump addon version to 2.2.0, update roadmap/changelog to reflect features and architecture changes.

* Update ROADMAP.md

* Delete NewDirectory.md

* pep 8

* Add slicer profiles support and UI

Introduce a new slicer_profiles package to extract, store and manage reusable slicer configs (JSON files in <blender_config>/3mf_slicer_profiles). Adds file-based CRUD (storage.py), Blender operators for load/rename/delete (operators.py), and public helpers (get_profile_config, extract_from_3mf). Integrates a Slicer Profile enum into the export UI and ExportOptions, caches dynamic enum items, and uses the selected profile as a fallback for Orca/Prusa exporters when stashed configs are absent. Adds an Advanced preferences tab with a collapsible slicer profile list and management actions, updates changelog, and registers the new operators; minor header/comment tidy-ups in panels modules.

* Turn off Debug Mode

* Remove Incorrect Ghostkeeper copyright lines

Remove the incorrect "Copyright (C) 2020 Ghostkeeper" header from many modules across the package. Only 16 files that have code from the original repository still contain that header, all new code/files contain only the Jack header

* Update CHANGELOG.md

* Refactor 3MF metadata panel into sections

Reorganise the 3MF Metadata sidebar into multiple collapsible sub-panels using layout.panel(). Adds a set of helper functions and constants to read/parse metadata (including stashed slicer configs, slicer vendor detection, paint colors, triangle-set counts) and a small formatting helper for counts. The main panel (VIEW3D_PT_3mf_metadata) is split into distinct sections: Scene Metadata, Object Info, Object Metadata, MMU Paint, Slicer Info, Materials and Triangle Sets, with improved handling of editable vs read-only keys and filtered custom entries. Also hides the panel in Texture Paint mode and tweaks UI/operator calls for a cleaner, more informative display.
Includes: Python Debugger for current file, a "Run All Tests" target, Blender targets for running unit/integration tests, running a specific test file or script in background mode with appropriate args, and an attach-to-process option.
Introduce Sculpt-mode Triangle Sets panel to name sculpt face sets (stored as JSON in mesh property) and operators to rename/clear names. Mirror applied triangle set IDs into Blender's .sculpt_face_set attribute on import and export named sets from either 3mf_triangle_set or .sculpt_face_set (with topology checks for imported index-based data). Add Smooth by Angle import option (prefs + import operator + API param) that applies Blender's auto-smooth on imported objects. Filter slicer profile picker by vendor groups and tweak preferences UI and changelog/roadmap to reflect these features.
* Support seam & support paint round-trip

Add full round-trip import/export support for seam and support paint layers (Orca/Bambu format).

- Read/write per-triangle paint_seam / paint_supports attributes and preserve them in ResourceObject.
- Export: extract auxiliary segmentation from dedicated UV textures and emit paint_seam/paint_supports attributes.
- Import: parse paint_seam / paint_supports, render them to separate UV textures and attach images for painting.
- New helpers for seam/support layer constants, UV naming, color keys, and image lookup; extended segmentation rendering to allow custom UV layer names, image names and default color override.
- UI: MMU Paint panel gains a layer switcher (Color / Seam / Support) with Initialize buttons and enforce/block brush toggles; new operators to init/switch layers and brush modes; new property to track active paint layer.
- Minor: bump addon version to 2.2.1 and update CHANGELOG/ROADMAP entries.

This enables enforcement/block semantics via a 2-state palette, dedicated textures per layer, and round-trip preservation of auxiliary paint data.

* Add Cura MMU data research to ROADMAP

Replace the generic seam/support painting research entry with a focused Cura MMU research task. Notes explain that Cura stores MMU data in a PNG using blue hues (up to 8 colors mapped to blue channel values like 1/255 = index 1, 2/255 = index 2), that it uses this for color zones but stores actual color data elsewhere, and that no seam/support data appears to be present. Marked as low priority since Cura is less used for MMU

* Update ROADMAP.md

* Orca exporter: grouping and material handling

Use collect_mesh_objects for selection and geometry checks and switch material detection from "multi-material" to any-material so single-colour objects are handled by the Orca path. Always emit per-triangle pid/p1 attributes so slicers like Orca/BambuStudio see colors even for single-material meshes. Add grouped-assembly support: detect parent EMPTYs, introduce group_info, and write a single wrapper/build item when grouping is requested; adjust bed-offset logic accordingly. Add _get_dominant_color and use it in model_settings to pick per-part extruder values via vertex_colors mapping. Minor typing import and operator changes to use the new material flag and preserve passthrough behavior for round-trip fidelity.
… bug fixes (#20)

* Enhance 3MF importer/exporter and add tests

Multiple bug fixes, performance/safety tweaks, API registration, and test additions for the 3MF addon:

- Register/unregister API on addon enable/disable (io_mesh_3mf/__init__.py).
- Fix segmentation triangle state (TriangleState.DEFAULT) (common/segmentation.py).
- Convert linear specular color to sRGB before hex encoding (export_3mf/materials/pbr.py).
- Add thumbnail enum cache to avoid Blender GC issues (export_3mf/operator.py).
- Improve Orca exporter UUID formatting and serialize vertex coordinates with configurable precision (export_3mf/orca.py).
- Guard expensive numpy unique() calls behind DEBUG_MODE in segmentation exporter (export_3mf/segmentation.py).
- Ensure temporary mesh cleanup with to_mesh_clear() in StandardExporter (export_3mf/standard.py).
- Consolidate slicer color readers to a single archive-open wrapper and add optional archive param to avoid repeated zip opens; add read_all_slicer_colors and update callers (import_3mf/slicer/colors.py, import_3mf/operator.py, import_3mf/slicer/__init__.py).
- Add a 3MF discovery helper for other addons to find/use this addon's API (io_mesh_3mf/threemf_discovery.py).
- Update tests and add many integration/unit tests covering export archive, triangles, import options, segmentation, paint, slicer profiles, Prusa/Orca behavior, thumbnails, and more (tests/...).

These changes improve compatibility with slicers, reduce redundant work, fix correctness issues, and expand test coverage.

* Add 3MF API discovery helpers and tests

Expose a discoverable 3MF API and add helper + tests.

- Register io_mesh_3mf.api in bpy.app.driver_namespace for other addons to discover and use the API without parsing addon directories. Provides API_VERSION, API_VERSION_STRING, API_CAPABILITIES and helper functions (is_available, get_api, has_capability, check_version) and auto-registers with a safe try/except.
- Add a standalone threemf_discovery.py helper that addons can copy/use to query the registry and call import/export/inspect convenience wrappers.
- Consolidate slicer color reading in import_3mf to use read_all_slicer_colors (single archive open, priority order).
- Add API.md documentation for API discovery and capabilities.
- Add unit tests: tests/unit/test_api_discovery.py (versioning, capability and registry checks) and tests/unit/test_import_segmentation.py (segmentation UV subdivision, rasterization and dilation routines).

These changes allow forward-compatible feature detection by third-party addons and simplify integration with the 3MF addon.

* Add AUTO export mode; respect render-disabled objects

Introduce a new AUTO material export mode (now the default) that auto-detects MMU paint, materials, and passthrough data to choose the best exporter (Standard, Orca, or Prusa). Add a skip_disabled option and UI controls to skip objects disabled for rendering (camera icon) and objects in excluded collections. Replace hide_get() checks with visible_get() for correct view-layer visibility, and thread skip_disabled through collect_mesh_objects and all exporters.

Refactor exporter selection: centralize dispatch logic into _select_exporter and add _scene_has_paint_textures helper. Update Standard/Orca/Prusa exporters and context/options to honor the new mode and skip_disabled flag.

Refactor MMU bake workflow: prepare all materials for EMIT bakes, pin texture UVs, fall back to DIFFUSE when needed, and add _cleanup_per_mat_state to reliably remove temporary nodes and restore material wiring.

Update tests and ROADMAP docs to reflect the AUTO default, add performance/clarity notes, and tweak contributing help text. Tests changed to use AUTO where appropriate.

* Default use_orca_format to AUTO; add dispatch tests

Change the API default from STANDARD to AUTO and refactor exporter dispatch logic. Added a new skip_disabled parameter (default True) and propagate it into ExportOptions. Updated the use_orca_format docstring to document AUTO | STANDARD | PAINT semantics and adjusted examples to use AUTO. The exporter selection now honors an explicit STANDARD mode and uses AUTO to pick Orca when project/object settings or materials are present, otherwise falling back to the Standard exporter. Added integration tests to verify AUTO/ STANDARD dispatch, component preservation in STANDARD mode, and that omitting the argument behaves like AUTO.

* Add API docs/site, docs build script & changelog

Add comprehensive Sphinx API documentation and the pre-built site (docs/site/) plus source rst files and conf. Includes docs/build.ps1 to build the API docs, new building-blocks/discovery/api rst pages, and mocked Blender modules for offline doc builds (docs/conf.py). Trim API.md to point to the generated docs, update README links, and ignore docs/_build in .gitignore. Add CODE_REVIEW.md and update CHANGELOG.md (2.2.2 notes). Small API/operator/segmentation/test updates to align export dispatch/defaults (use_orca_format now dispatches AUTO) and fix paint/export behavior; update examples in docs and copilot instructions accordingly. Prebuilt HTML/static assets are committed so users can browse docs without building.

* pep 8
Detect Empties with children and map mesh children into group assemblies; build a groups list plus ungrouped objects and apply bed-offsets accordingly. Update main export flow and function signatures (write_main_model, write_orca_metadata, generate_model_settings) to emit multiple wrapper objects, build items, plate/model_instance and assemble entries for each group and for ungrouped meshes. Metadata generation now aggregates per-group extruder selection from member dominant colors and preserves per-object overrides. Add debug logging for detected groups and export structure.
Add robust, layered discovery for the 3MF addon and make registry behavior resilient to Blender restarts and explicit disable. Introduces an _explicitly_disabled flag and re-register logic in api.is_available/get_api, expands API capability flags (parameter-level options like global_scale, compression, thumbnail, use_components, auto_smooth, subdivision_depth), and updates the standalone threemf_discovery helper to cache results, auto-resolve addon paths via addon_utils, and prefer driver_namespace/direct-import fallbacks. Update docs and generated site docs to document the recommended direct-import pattern and the standalone helper. Tests updated to cover registration/unregistration, discovery fallbacks, capability checks, and the new behaviors. CHANGELOG updated with multi-group assembly export note.
Make paint baking more robust and add region/geometry-aware quantization and rasterization.

Key changes:
- Safely unregister depsgraph handler in __init__.py by checking existence before removal.
- Large refactor in bake.py: add _compute_neighborhood_brightness and pass neighborhood context into _hue_aware_distance to bias achromatic matches toward local brightness.
- Replace per-pixel quantize logic with _compute_palette_index_map and simplify _quantize_pixels to use the index map for in-place palette assignment.
- Add UV-aware rasterization utilities: _rasterize_island_map, _uv_edge_shared to prevent region bleeding across UV islands.
- Add vertex-color fast-path detection and rasterization (_detect_vertex_color_source, _rasterize_vertex_colors) to skip expensive Cycles bake when possible.
- Add face-based vectorized workflows: _compute_face_filaments and _rasterize_face_colors for fast flat-face fills of textures.
- Implement region-based segmentation and merging: _flood_fill_segmentation, _compute_gradient_magnitude, _merge_small_regions to produce contiguous, edge-aware regions before quantization.
- Numerous performance and robustness improvements (vectorized batching, tiny-triangle fast paths, UV bleed filling) and corresponding unit test updates.

Overall this enables more perceptually correct color snapping (especially in shadows/greys), prevents UV-island leakage, and accelerates common vertex/face color workflows.
Add a new 2.3.0 changelog entry describing Region-Aware Quantization, Vertex Color fast path, UV-aware segmentation/bleed, adaptive bake UI, multi-group export and API discovery changes, plus bug fixes and technical notes. Also bump io_mesh_3mf/blender_manifest.toml version to 2.3.0.
Add adaptive pre-subdivision for PAINT exports to avoid blocky segmentation: subdivide_mesh_for_segmentation() detects UV-area-heavy faces and splits them in the temporary to_mesh() copy; integrated into Orca and Standard exporters and passed through to texture_to_segmentation.

Refactor paint bake internals by splitting the monolithic bake module into paint.quantize and paint.vertex_colors (new files added) and re-exporting them from paint.__init__. Add BaseExporter._find_paint_texture helper and update _extract_auxiliary_segmentation/texture_to_segmentation signatures to accept pre-subdivided meshes. Update changelog and bump blender add-on version to 2.4.0. Tests updated accordingly.
Small fix to avoid issues such as #23

Rename the export option from Skip Disabled to Include Disabled and update codepaths to use the new option name. The boolean semantics are flipped (include_disabled=False by default) so the default behavior is unchanged (disabled objects remain excluded unless opted in). All relevant modules were updated (operator, context, components, standard, orca, prusa) and the API export wrapper preserves backwards compatibility by mapping the old skip_disabled parameter to the new include_disabled flag. Changelog entry added describing the UX change.
When validating the selected objects for 3MF export, use a more permissive collection so disabled or hidden meshes parented to empties are not rejected prematurely. Pass include_disabled=True (alongside export_hidden=True) to collect_mesh_objects and update the comment to clarify this pre-filtering behavior.

Fixes the core issue of #23
Generate Slic3r_PE_model.config during 3MF export when none is stashed: add material->extruder mapping using object materials and triangle counts (new _generate_model_config in prusa.py) and import material_to_hex_color. Ensure generated config is written into the archive and log debug messages. Fix UV iteration bug in segmentation (use consistent loop variable for uv access). Bump addon version to 2.4.1 and apply minor formatting/import ordering cleanups in paint package and quantize file.

This fixes #24
Preserve original texture paths when available (round-trip) and fall back to sanitized filenames otherwise. Only add a default .png content type if no more specific content type was recorded to avoid overriding imported types. Namespace-qualify relationship attributes and write the rels XML with a default namespace to avoid ns0: prefixes. Accumulate texture relationships across PBR, standard, and passthrough pipelines and write them once at the end to prevent each pass from overwriting the rels file.

Found thanks to #25, hadn't realized a spec difference that was leading to this tool's 3mf files being rejected by tools needing spec compliance.
Add coverage for texture packaging and relationship serialization.

- Add integration test (tests/integration/test_3mf_consortium_samples.py) to verify sphere_logo.3mf roundtrip preserves the 3MF texture OPC content type, includes texture files, writes 3D/_rels/3dmodel.model.rels, avoids ns0: prefixes, and ensures rel targets exist in the archive.
- Extend unit tests (tests/unit/test_annotations.py) to exercise Annotations.write_content_types() behavior: preserve the 3MF texture content type for .png, default to image/png when no annotations exist, ensure valid XML, and avoid ns0: prefixes. Also add required imports.
- Add new unit tests (tests/unit/test_texture_rels.py) for write_texture_relationships() covering namespace declarations, absence of ns0: prefixes, valid XML, correct Relationship elements (Type, Target, Id uniqueness), empty-dict behavior, path preservation, and ensuring the global ElementTree namespace registry is not mutated.

These tests catch and prevent regressions around OPC content types, texture relationships, namespace handling, and archive entry targets.
Add changelog entry for v2.4.2 describing fixes to 3MF texture export (OPC content-type correctness, texture path preservation, accumulating texture relationships, and namespace prefix serialization) and new tests covering relationship and content-type behavior. Also bump io_mesh_3mf/blender_manifest.toml version to 2.4.2.
Introduce a new export option `flatten_hierarchy` (API bump to 1.1.0) and propagate it to operator UI, ExportOptions, and exporter logic to write child meshes as top-level build items. Improve 3MF spec compliance: skip faceless mesh objects and objects producing no triangles, add OPC texture content type constant and default .png/.jpg/.jpeg mapping, set model root attributes (`unit="millimeter"`, `xml:lang="en-US"`), remove duplicate core property xmlns declarations, and ensure proper namespace prefix registration and required-extensions declaration. Misc: rename texture archive folder to `3D/Textures`, remove unused basematerials when all faces use textures, and add related warnings/logging. Unit tests updated to reflect content type and extension prefix behavior.

Officially fixes #25
Bump API_VERSION patch to 1.1.1 and ensure explicit object lists are exported correctly by bypassing visibility and render-disable filters (set options.export_hidden and options.include_disabled when caller provides objects). Also add a [Content_Types].xml Override for /Metadata/thumbnail.png when the .png default MIME type isn't image/png so Windows Explorer's OPC thumbnail handler recognises the thumbnail as image/png.
Forward export_hidden/include_disabled through collection and detection code: collect_face_colors and detect_linked_duplicates now accept export_hidden/include_disabled and callers (orca, prusa, standard, and api non-manifold check) pass ctx.options values. Bump addon version to 2.4.4 and update CHANGELOG. Add integration tests covering include_disabled export behavior, component detection, API explicit-object exports, and thumbnail OPC content-type override.
Replace multipletextures.3mf with sphere_logo.3mf in the multipletextures test to avoid Blender headless hanging during roundtrip (multipletextures.3mf is ~2 MB). Update the test docstring to explain the change; sphere_logo.3mf covers the same Materials Extension elements and keeps expected_elements=['texture2d','texture2dgroup'].
Import and export support for Orca/BambuStudio modifier part subtypes (normal_part, modifier_part, support_enforcer, support_blocker, negative_part). Reads/writes part subtype and per-object/per-part slicer overrides from Metadata/model_settings.config, preserves wrapper->part hierarchy (creates Empty parents for multi-part assemblies), and round-trips settings via custom properties (3mf_part_subtype, 3mf_orca_settings, 3mf_orca_wrapper_settings). Non-normal parts no longer get paint/segmentation data on Orca export; viewport-coloured shared materials are applied for modifier/support/negative parts. Adds API capability and bumps API_VERSION to 1.2.0 with inspect_3mf returning part_subtypes, updates docs and changelog, increments addon manifest version, and adds integration tests plus sample 3mf resources. Also includes helper utilities for reading/writing stashed settings and prevents part ID collisions by using composite (wrapper_id, part_id) keys.
Add support for part display names from slicer model_settings: introduce ctx.part_names in ImportContext and initialize it in api and operator. Collect part names when parsing ORCA/BambuStudio metadata (stored keyed by (wrapper_id, part_id)). Use these names as the highest-priority Blender object name when building objects (falling back to <object> Title metadata or "3MF Object"). Also reuse the composite key for applying part subtype. Improves object naming fidelity when importing multi-part 3MF files.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants