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 150 commits into
Ghostkeeper: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 150 commits into
Ghostkeeper:masterfrom
Clonephaze:master

Conversation

@Clonephaze

@Clonephaze Clonephaze commented Oct 8, 2025

Copy link
Copy Markdown

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.
Replace legacy Markdown issue templates with structured GitHub Issue Forms. Deleted bug_report.md and feature_request.md and added bug_report.yml and feature_request.yml with validated fields (addon/blender version, OS, area, reproduction steps, etc.), default labels/assignees, and improved guidance for reporters. Also added ISSUE_TEMPLATE/config.yml to disable blank issues and provide contact links, and introduced a PULL_REQUEST_TEMPLATE.md for consistent PR descriptions.
Add repository config files: .github/CODEOWNERS to auto-request reviews from @Clonephaze; .github/workflows/stale.yml to run daily (06:00 UTC) and mark issues stale after 60 days and close after 14 days (exempting labels: pinned, bug, in progress) while ignoring PRs; and SECURITY.md documenting supported versions and a private vulnerability reporting process via the repo Security tab.
Update CI to actions/checkout@v4 and setup-python@v5 (Python 3.12) and include tests/ in pycodestyle checks. Apply widespread stylistic changes across test files: normalize to double quotes, add trailing commas, adjust whitespace and line breaks, tweak regex/string literal quoting, use clearer with(...) contexts, and minor readability refactors. Changes are formatting-only and do not alter test logic or behavior.
Generates a Slic3r_PE_model.config with one <object> and one <volume> per original part (firstid/lastid cumulative) and preserves world transforms (vertex positions baked). Improve material_to_hex_color() to walk node trees and read colours from Principled BSDF and other shader nodes (Diffuse, Glossy, Emission, Glass, Toon, Velvet, standalone RGB nodes, and legacy diffuse_color), skipping the default auto-generated gray. Add scripts/inspect_blend.py for inspecting scene objects/materials. Update tests to assert a single combined object/build item, validate generated model config volumes and IDs, and check Z-position preservation and segmentation handling.
Add five discussion templates under .github/DISCUSSION_TEMPLATE: announcements, bug-reports, feature-ideas, showcase, and support. Each template provides structured fields, labels, and validations (e.g., addon/blender version, area dropdowns, reproduction steps, media) to standardize community reporting, triage, idea brainstorming, and showcases.
Rename .github/DISCUSSION_TEMPLATE/showcase.yml to .github/DISCUSSION_TEMPLATE/showcase-gallery.yml to clarify the template's purpose. This is a pure rename (100% similarity) with no content changes.
Rename .github/DISCUSSION_TEMPLATE/support.yml to .github/DISCUSSION_TEMPLATE/support-troubleshooting.yml to better reflect the template's purpose for support/troubleshooting discussions. No content changes (100% similarity).
Updated badge links to be clickable in README.
Introduce a new ProgressWindow feature and integrate it across import, export and bake flows.

- Add progress.py and progress_win.py to spawn a floating browser progress card (phased stepper, cancel support, filament swatches).
- Expose a new addon preference to toggle the progress window and add API capability "progress_window"; bump API_VERSION to 1.3.0 and addon version to 2.6.1.
- export_3mf: new show_progress_window param, wrap/forward on_progress to update the browser card, and ensure proper start/finish on errors and successful export.
- Export and Import operators: pre-flight heuristics call should_show_progress(), spawn ProgressWindow and forward Blender progress updates into the card (including multi-file import progress), and ensure finish() on end.
- Bake/paint changes: integrate ProgressWindow into MMU bake flows (bake_cycles and vertex-color fast path), add cancel checks and UI updates; refactor bake execution into a safe wrapper to guarantee teardown.
- UV improvements: add new MMU UV method "EXISTING" to copy a user UV layer into MMU_Paint (with a new existing_uv_layer property and autocomplete), adjust UI panels and disable dissolve where appropriate; unify UV handling across initialize, bake and helpers.
- Segmentation: replace ad-hoc point checks with a barycentric sampling grid that scales with triangle pixel footprint to better detect narrow features.

Overall this change adds a user-facing progress card for long operations, safer progress handling, a new UV workflow for using existing unwraps, and some robustness/improvements in segmentation sampling.
Introduce native progress window support and performance-focused refactors across the exporter. Adds a show_progress_window preference and bumps addon version / changelog for 2.7.0. Logging gains a --debug-aware timing_debug helper.

Major export changes: geometry is now serialized as pre-built raw XML strings stored in a side-cache and injected by a new streaming writer to avoid ElementTree's Python-level DOM walk. Vertex/triangle extraction is vectorized with numpy + foreach_get, per-slot attribute fragments are precomputed, and numerous hot loops were rewritten to build raw XML directly — reducing Python overhead for very large meshes. ExportContext progress updates can now accept an explicit phase index, and phase mapping was adjusted so object/segmentation work stays within the intended progress phases. Materials collection was optimized using foreach_get, and Orca/Standard exporters updated to use the raw-geometry streaming path and timing hooks.
Reformat code for readability across multiple modules: wrap long HTML/SVG string literals in progress_win.py using parentheses and line breaks; wrap geometry imports in standard.py across multiple lines; add/adjust blank lines and minor whitespace cleanups in api.py, export_3mf/geometry.py, paint/bake.py, paint/properties.py, and progress.py. These are non-functional style changes to improve maintainability and line length compliance.
Corrects a bug in export_3mf where ElementTree's internal _namespace_map was inverted; the mapping is now copied directly (preserving {uri: prefix}) and a clarifying comment was added.

In import_3mf, mesh creation was optimized by using numpy and Blender's foreach_set APIs to bulk-populate vertices, loops and polygons instead of mesh.from_pydata. This reduces Python-level iteration and significantly speeds up import for large meshes (100K+ tris), and ensures edges are calculated via mesh.update(calc_edges=True). A numpy dependency was added and the function includes a brief note on the performance benefit.
Add a manual performance benchmark script (tests/run_benchmarks.py) and a large test resource (tests/resources/large_multicolor.3mf). Update CHANGELOG.md to note faster mesh creation on import and the new export_3mf show_progress_window parameter. Adjust integration tests: test_export_geometry now uses get_raw_geometry and verifies unqualified vertex attributes from the raw cache, and test_include_disabled asserts that Prusa export produces a single combined mesh with more triangles than a single cube. These changes support performance measurement and align tests with the new raw geometry handling.
Update generated docs for the 3MF Format API to v1.3.0 and document several new discovery/import/export behaviors. Key changes: bump API version string; add a .buildinfo backup; improve discovery robustness with an _explicitly_disabled flag and auto re-register in is_available/get_api; document new API options and context fields (global_scale, compression, thumbnail, use_components, auto_smooth, subdivision_depth, flatten_hierarchy, modifier_parts, progress_window, scene_unit, etc.); add parsing of Orca/BambuStudio model_settings.config to surface part_subtypes and related metadata; add optional browser progress window support for export_3mf (show_progress_window) and progress callback wrapping; update export options (include_disabled semantics) and various context/state fields; and refresh static doc asset version hashes. Mostly documentation and generated module doc updates reflecting the new API features and behavior.
Fix several progress window bugs and harden spawn/open behavior.

Changes:
- Bump API and addon versions (API 1.3.1, addon 2.7.1).
- API: wire ProgressWindow into exporter (ctx.progress = _pw) so internal _progress_update() calls reach the UI; ensure _pw.finish() always runs by moving it to a finally block and clear ctx.progress on exit.
- Export context: add _progress_range field and remap Blender 0–100 progress values to phase indices (weights per phase); simplify _progress_update signature.
- ProgressWindow: add IPC port file, clear stale IPC files, wait for subprocess server readiness and request Blender to open the URL (or warn on timeout); suppress subprocess stdout/stderr; refine when the window is shown.
- progress_win.py: improve Chromium/Edge/Brave detection (Windows registry and common install paths, macOS, Linux), always attempt --app launch then fallback to webbrowser, write port metadata so Blender knows the server is ready; streamline HTML/JS (elapsed timer, minor UI/CSS tweaks).
- Minor tidy-ups: import warn where needed in bake.py and remove/adjust some debug/warn messages.

These fixes address: missing live updates when called via the API, progress window not closing on success, more reliable browser launching across platforms, and more accurate phase reporting in the UI.
Exporters (Standard/Orca) passed a `phase` kwarg to ExportContext._progress_update, causing a TypeError and export crashes. Add an optional `phase` parameter and use it directly when supplied; otherwise fall back to the existing computed phase boundaries (with correct handling of the final phase). Update CHANGELOG and bump blender_manifest version to 2.7.2. Fixes #33
Add unit tests covering ExportContext._progress_update behavior and signature (regression: Issue #33). Introduces a helper to create a fake Blender-like progress context and tests that _progress_update accepts value-only and value+message calls, accepts the phase keyword, preserves monotonic progress, is a no-op when no context is present, forwards phase and message to a configured progress object, and auto-derives phase when omitted. Also adds an import for the types module.
Large overhaul of README.md: updates badges and release URLs, rephrases the intro, and restructures content into Why Use It, Documentation, Quick Start, Importing/Exporting, MMU Paint Suite, Slicer Profiles, Feature Summary, Specification Support, and Troubleshooting. Adds many user and API doc links, clarifies import/export modes and options, highlights Version 2.0.0+ public API and Blender 5.0 target, and improves guidance for slicer workflows and MMU painting.
* Introduce three-tier progress system and fixes

Implement a three-tier progress system (NONE / VIEWPORT / BROWSER) with tunable thresholds and a new get_progress_mode API. Add a lightweight in-viewport ProgressReporter/ViewportProgressBar, keep the browser-based reporter but improve lifecycle handling (kill stale PIDs, per-session browser profile, auto-close, non-blocking finish and smoother timer). API: export_3mf gains a progress_mode parameter (show_progress_window kept as deprecated AUTO), and call sites updated to use ProgressReporter/get_progress_mode. Fix a k-means++ initializer crash in color detection (handle zero-sum distances to avoid NaN probabilities). Bump addon version to 2.7.3 and add changelog entry; add unit test for progress behavior and update various modules to match new progress interfaces and naming.

* pycodestyle

* Fix near-white handling and k-means crashes

Improve texture color detection and robustify k-means. Treat near-white pixels as background only when they cover <5% of opaque image area so intentional white content (e.g. stripes) is not discarded; log whether near-white pixels were kept or removed. Handle degenerate k-means++ initialization that can return fewer than k centers by using the actual center count (k_actual) for the update loop and bincount, preventing NaN/IndexError crashes. Also update CHANGELOG.md to document these fixes.
…rckley

This drops the separate browser-based progress UI and standardizes progress reporting on the in-viewport bar only. The add-on preference for `show_progress_window` and the `ProgressWindow` subprocess stack were removed, browser mode thresholds were deleted, and `ProgressReporter("BROWSER")` now maps to viewport mode for backward compatibility. API metadata/docs were updated (`API_VERSION` 1.3.2 and capability/docs cleanup), obsolete progress window files were deleted, tests were updated to reflect the new mode behavior, and manifest build exclusions were added.
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