CommunityCodierung & Entwicklunggithub.com

slicer-3mf

Edit 3MF projects saved by slicers (Creality Print, OrcaSlicer, Bambu Studio) from Python with lib3mf-slicer-settings — swap meshes without losing print settings/plates/thumbnails, scrub private paths, apply print settings by the slicer's own key names. Use when generating print-ready 3MF exports, OpenSCAD → slicer pipelines, or anything touching slicer project files.

Was ist slicer-3mf?

slicer-3mf is a Claude Code agent skill that edit 3MF projects saved by slicers (Creality Print, OrcaSlicer, Bambu Studio) from Python with lib3mf-slicer-settings — swap meshes without losing print settings/plates/thumbnails, scrub private paths, apply print settings by the slicer's own key names. Use when generating print-ready 3MF exports, OpenSCAD → slicer pipelines, or anything touching slicer project files.

Funktioniert mit✓Claude Code~Codex CLI~Cursor
Part ofMobile
npx skills add https://github.com/gmarceau/skills/tree/HEAD/skills/slicer-3mf

Installed? Explore more Codierung & Entwicklung skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

In Ihrer bevorzugten KI fragen

Öffnet einen neuen Chat, in dem dieser Agent-Skill bereits geladen ist.

Dokumentation

Editing slicer 3MF projects (lib3mf-slicer-settings)

Repo: https://github.com/gmarceau/lib3mf-slicer-settings (GPL-3.0, pure Python, mypy --strict, plumbum + pydash). Working copies live under ~/code/ (e.g. ~/code/dragon-claude-3mf uses its step1–4 pipeline).

Why

General 3MF libraries (lib3mf, trimesh) drop the slicer's own entries (Metadata/project_settings.config, Metadata/model_settings.config, thumbnails) when they write. This library edits the 3MF zip in place — only rewritten entries change; every other entry keeps its exact bytes and order.

Core recipe (OpenSCAD export → printable project)

from lib3mf_slicer_settings import (
    apply_print_settings, is_slicer_project, private_paths,
    put_3mf, read_mesh, read_print_settings, scrub_paths, swap_mesh,
)

report = swap_mesh("hanger_print.3mf", read_mesh("hanger.stl"))
print(report.objects, report.new_size, report.dropped_paint)

# install a fresh 3MF without losing the slicer project's settings
if (report := put_3mf("build/hanger.3mf", "hanger_print.3mf")) is not None:
    print(report.objects, report.new_size, report.dropped_paint)

apply_print_settings("hanger_print.3mf", {
    "wall_loops": 5, "sparse_infill_density": "40%", "layer_height": 0.2,
    "outer_wall_speed": 100,      # per-extruder list: value fans out to every entry
    "fan_max_speed": [50],
})
print(read_print_settings("hanger_print.3mf")["wall_loops"])   # "5"

scrub_paths("hanger_print.3mf")          # cut absolute source_file paths to bare names
assert private_paths("hanger_print.3mf") == []   # verify before publishing!

Rules that bite

  • Always scrub_paths + private_paths-validate before publishing — slicers record absolute import paths that leak folder structure.
  • Print-settings keys are the slicer's own names from Metadata/project_settings.config (wall_loops, not wall_loop — an unknown key errors with a "did you mean" and writes nothing). Values are stored the slicer's way: True → "1", 0.2 → "0.2".
  • Changed keys are filed into different_settings_to_system (process/filament/printer slot via the sections.json classifier cached in the user cache dir; LIB3MF_PROFILES points at slicer profiles elsewhere). Unknown-classification keys still get set and land in report.unclassified.
  • Presets stay selected — you only override, you don't replace.
  • swap_mesh refuses projects with objects of different bounding-box sizes (can't tell which to replace); replaces all copies when sizes match. Per- object overrides (model_settings.config) and triangle painting (supports/seams/colour) don't survive a swap — report.dropped_paint flags it.
  • Project layout is shared by Creality/Orca/Bambu (PrusaSlicer differs): 3D/3dmodel.model (placements), 3D/Objects/object_N.model (bbox-centred meshes), Metadata/project_settings.config (JSON), Metadata/model_settings.config (XML), Metadata/plate_N.png.

Environment conventions

  • is_slicer_project() first; a plain 3MF (OpenSCAD export) written with put_3mf is just copied fresh — the report is None then.
  • Verify with the repo's gates: task (pytest + mypy --strict); test helpers in lib3mf_slicer_settings.testing build fake projects/boxes/STLs.

Verwandte Skills