#!/usr/bin/env python3 """Generate a minimal SuperSlicer-style 3MF, faithful to SuperSlicer's exporter (merill/SuperSlicer, a fork of PrusaSlicer's 3MF writer): - Application metadata: "SuperSlicer-2.6.59.0" (no "PrusaSlicer" substring) - 3D/3dmodel.model: with vertices/triangles as direct children (3MF core spec) and NO name attribute (SuperSlicer/PrusaSlicer do not write object names into the model xml; they live in the sidecar configs) - Object names live in the sidecars Metadata/Slic3r_model.config, Metadata/Slic3r_PE_model.config, Metadata/SuperSlicer_model.config as - No 3D/_rels/3dmodel.model.rels, no Bambu project files Usage: make_superslicer_3mf.py OUT.3mf [APPLICATION_STRING] """ import sys, zipfile OUT = sys.argv[1] if len(sys.argv) > 1 else "superslicer_style.3mf" APP = sys.argv[2] if len(sys.argv) > 2 else "SuperSlicer-2.6.59.0" MODEL = """ {APP} """.format(APP=APP) def model_config(): objs = [] for oid, name in [(1, "LDO_Skirt_Left"), (2, "LDO_Skirt_Right")]: objs.append(f' \n' f' \n' f' \n' f' \n') return '\n\n' + "".join(objs) + '\n' CONTENT_TYPES = """ """ RELS = """ """ with zipfile.ZipFile(OUT, "w", zipfile.ZIP_DEFLATED) as z: z.writestr("[Content_Types].xml", CONTENT_TYPES) z.writestr("_rels/.rels", RELS) z.writestr("3D/3dmodel.model", MODEL) for f in ("Metadata/Slic3r_model.config", "Metadata/Slic3r_PE_model.config", "Metadata/SuperSlicer_model.config"): z.writestr(f, model_config()) print("wrote", OUT, "with Application =", APP)