Desktop app for designing parametric 3D models in CadQuery together with the coding agent of your choice
TypeScript 3d-modeling3d-printing3d-printing-toolsagentagentic-aiai-cadcadcadqueryclaude-codecodexelectronfemllmmacdmakeropencodeparametric-designpythonsteptext-to-cad
App: Netz-Einstellungen im Export-Menü, Warnungen des Exports anzeigen
Kai-Jungsthoefela8ef5ee9f830
diff --git a/app/resources/help/export.png b/app/resources/help/export.pngindex 58d58ff..7a61382 100644Binary files a/app/resources/help/export.png and b/app/resources/help/export.png differdiff --git a/app/resources/skills/soma-app.md b/app/resources/skills/soma-app.mdindex d80eae0..e7f0cf5 100644--- a/app/resources/skills/soma-app.md+++ b/app/resources/skills/soma-app.md@@ -198,9 +198,12 @@ after that Ctrl S saves to the same file. Copy or send the file like any other d1. **Scope**: all parts, or only the selected one.-2. **Formats**: for 3D printing (STL, 3MF), CAD (STEP, IGES), graphics and 2D (DXF, SVG). All parts become one file per part in a folder you choose.-3. **Everything as ZIP**: the whole model with code, results and history, for someone without SOMA.-4. **As CadQuery script**: the model as plain CadQuery for CQ-editor, VS Code with ocp_vscode and other tools, without SOMA.+2. **Mesh settings**: closed by default, click to open. Units, the axis pointing up and the mesh density for STL, 3MF, AMF, OBJ, GLB and GLTF. "Auto" writes GLB and GLTF in meters with Y up, as game engines (Unity, Unreal, Godot) and Blender expect them, and the other formats in millimeters with Z up, as slicers expect them. "Coarse" gives fewer triangles, for example for a game, "Fine" smoother curves. The settings are remembered, and the closed row shows what differs from Auto.+3. **Formats**: for 3D printing (STL, 3MF), CAD (STEP, IGES), graphics and 2D (DXF, SVG). All parts become one file per part in a folder you choose.+4. **Everything as ZIP**: the whole model with code, results and history, for someone without SOMA.+5. **As CadQuery script**: the model as plain CadQuery for CQ-editor, VS Code with ocp_vscode and other tools, without SOMA.++If a mesh is not closed, the message after the export says why, for example which faces could not be meshed and where they are.Reference parts (for example an imported circuit board) are not included in "All parts".diff --git a/app/resources/template/AGENTS.md b/app/resources/template/AGENTS.mdindex 7c898c6..1b6e55e 100644--- a/app/resources/template/AGENTS.md+++ b/app/resources/template/AGENTS.md@@ -41,6 +41,7 @@ Run them in this terminal. They work without the app.| `soma build` | Runs `model.py`, writes `output/model.step` and the viewer cache. **Run it after every change and read the result.** On errors it prints the file, line and message || `soma export <Part> --format stl` | Exports one part (formats: step, stl, 3mf, amf, brep, iges, obj, vrml, glb, gltf, dxf, svg) || `soma export --all --format step` | Exports all parts except references |+| `soma export <Part> --format glb --detail coarse` | Mesh formats (stl, 3mf, amf, obj, glb, gltf) take `--units mm\|cm\|m\|in`, `--up z\|y`, `--detail coarse\|normal\|fine` or `--tolerance <mm>`. Default: glb/gltf in m with Y up (game engines, Blender), the others in mm with Z up || `soma render` | Saves a picture of the current model to `renders/view-iso.png` (`--view top` or a direction `--view=1,-2,1`, `--hide`/`--only` parts or groups, `--fit` parts, `--zoom 2`, `--size 1280x800`, `--out`). **Open the picture and look at it** to check your work, also inside: hide what is in the way. Needs the app with this model open, it renders with the app's viewer || `soma analyze overhang` (or `thickness`, `clearance`) | Value at every spot of the surface with a summary per part. Details in the skill for analysis || `soma analyze fem analyses/x.py` | Stresses, safety and deflection under a load case described in `analyses/x.py`. Details in the skill for FEM |diff --git a/app/src/main/main.ts b/app/src/main/main.tsindex 1cfd071..02fc644 100644--- a/app/src/main/main.ts+++ b/app/src/main/main.ts@@ -110,7 +110,7 @@ function registerIpc(ctl: ProjectController): void {ipcMain.handle('build:cancel', () => ctl.need().builds.cancel());ipcMain.handle('build:setAuto', (_e, on: boolean) => ctl.need().builds.setAuto(!!on));ipcMain.handle('build:status', () => ctl.need().builds.status);- ipcMain.handle('build:export', (_e, format: string, part: string | null) => ctl.exportModel(String(format), part ? String(part) : null));+ ipcMain.handle('build:export', (_e, format: string, part: string | null, mesh: unknown) => ctl.exportModel(String(format), part ? String(part) : null, mesh));ipcMain.handle('fs:list', () => listFiles(dir()));ipcMain.handle('fs:import', (_e, paths: string[]) => importInputs(dir(), Array.isArray(paths) ? paths.map(String) : []));diff --git a/app/src/main/projects.ts b/app/src/main/projects.tsindex ee79980..bd9ccd0 100644--- a/app/src/main/projects.ts+++ b/app/src/main/projects.ts@@ -3,7 +3,7 @@ import fs from 'node:fs';import os from 'node:os';import path from 'node:path';import type {- AnimBuildResult, AnimList, CadQueryImportResult, DrawingBuildResult, DrawingList, ExportResult, FileViewResult, GitLog, MeasureEntity, MeasurePrepared, MeasureRequest, MeasureResponse, ModelMap, OpenResult, PreviewResult,+ AnimBuildResult, AnimList, CadQueryImportResult, DrawingBuildResult, DrawingList, ExportResult, FileViewResult, MeshExportOptions, GitLog, MeasureEntity, MeasurePrepared, MeasureRequest, MeasureResponse, ModelMap, OpenResult, PreviewResult,ParamResult, ParamState, ParamValue, ProjectInfo, RemoveResult, RenderResult, RestoreResult, ResultEntry, SaveResult, SaveState, SkillInfo, SkillResult,} from '../shared/types';import { affectsAnimation } from '../shared/editable';@@ -73,6 +73,18 @@ function lastJson<T>(out: string): T | null {}const safeFileName = (n: string) => n.replace(/[<>:"/\\|?*\x00-\x1f]/g, '_').trim() || 'Model';/** Modelle werden als .soma gespeichert (E79), innen eine ZIP. Geöffnet wird auch eine .zip. */+/** Netzformate, für die `soma export` Einheit, Achse und Detailstufe kennt (Issue #8) */+const MESH_EXPORT_FORMATS = ['stl', '3mf', 'amf', 'obj', 'glb', 'gltf'];+/** Einstellungen aus dem Renderer als Argumente für `soma export`. Was nicht passt, fällt weg: Dann gilt die Vorgabe des Formats. */+function meshExportArgs(mesh: unknown): string[] {+ const o = (mesh && typeof mesh === 'object' ? mesh : {}) as MeshExportOptions;+ const out: string[] = [];+ if (o.units === 'mm' || o.units === 'm') out.push('--units', o.units);+ if (o.up === 'z' || o.up === 'y') out.push('--up', o.up);+ if (o.detail === 'coarse' || o.detail === 'normal' || o.detail === 'fine') out.push('--detail', o.detail);+ return out;+}+const MODEL_EXT = '.soma';const isModelFile = (p: string) => p.toLowerCase().endsWith(MODEL_EXT);/** Pfad mit .soma: „x“ und „x.zip“ werden „x.soma“. */@@ -355,9 +367,10 @@ export class ProjectController {* Zukaufteile) als je eine Datei in einen gewählten Ordner. soma schreibt in einen leeren Ordner unter Temp, die App* kopiert danach. So landet nichts in exports/ des Projekts, und eine vorhandene Datei wird nie ohne Rückfrage ersetzt.*/- async exportModel(format: string, part: string | null): Promise<ExportResult> {+ async exportModel(format: string, part: string | null, mesh?: unknown): Promise<ExportResult> {const s = this.need();if (!/^[a-z0-9]{2,5}$/.test(format)) return { ok: false, files: [], error: `Unknown format: ${format}` };+ const meshArgs = MESH_EXPORT_FORMATS.includes(format) ? meshExportArgs(mesh) : [];const last = getAppState(s.id).exportDir;const startDir = last && fs.existsSync(last) ? last : documentsDir();const target = await chooseExportTarget(this.getWin(), part@@ -368,7 +381,7 @@ export class ProjectController {try {tmp = fs.mkdtempSync(path.join(os.tmpdir(), 'soma-export-'));// `--` vor dem Namen: Bauteilnamen dürfen mit einem Minus beginnen, ohne als Option zu gelten- const args = ['export', '--format', format, '--project', s.dir, '--out', tmp, ...(part ? ['--', part] : ['--all'])];+ const args = ['export', '--format', format, ...meshArgs, '--project', s.dir, '--out', tmp, ...(part ? ['--', part] : ['--all'])];const r = await runSoma(args, s.dir, 10 * 60 * 1000);if (!r.ok) {const msg = (r.err || r.out).trim().split(/\r?\n/).slice(-3).join('\n');@@ -400,7 +413,9 @@ export class ProjectController {}const dest = part ? plan[0][1] : target;patchAppState(s.id, { exportDir: part ? path.dirname(dest) : target });- return { ok: true, files: plan.map(([, d]) => d), target: dest };+ // Hinweise von soma (z. B. ein Netz, das nicht geschlossen ist, mit den betroffenen Flächen) an den Benutzer weitergeben+ const warnings = r.out.split(/\r?\n/).filter((l) => l.startsWith('warning: ')).map((l) => l.slice(9).trim());+ return { ok: true, files: plan.map(([, d]) => d), target: dest, ...(warnings.length ? { warnings } : {}) };} catch (e) {return { ok: false, files: [], error: `Export failed: ${e instanceof Error ? e.message : String(e)}` };} finally {diff --git a/app/src/preload/preload.ts b/app/src/preload/preload.tsindex 5ec76c4..2252de0 100644--- a/app/src/preload/preload.ts+++ b/app/src/preload/preload.ts@@ -39,7 +39,7 @@ const api: SomaApi = {setAuto: (on) => ipcRenderer.invoke('build:setAuto', on),status: () => ipcRenderer.invoke('build:status'),onStatus: (cb) => { ipcRenderer.on('build:status', (_e, s) => cb(s)); },- export: (format, part) => ipcRenderer.invoke('build:export', format, part),+ export: (format, part, mesh) => ipcRenderer.invoke('build:export', format, part, mesh ?? null),},fs: {list: () => ipcRenderer.invoke('fs:list'),diff --git a/app/src/renderer/index.html b/app/src/renderer/index.htmlindex add7b80..2f138bb 100644--- a/app/src/renderer/index.html+++ b/app/src/renderer/index.html@@ -458,6 +458,15 @@<div id="menu-export" class="menu wide" role="menu" hidden><div class="mh">SCOPE</div><div class="seg"><button id="exp-all" class="on" aria-pressed="true">All parts</button><button id="exp-sel" aria-pressed="false" disabled>Selection only</button></div>+ <button id="exp-mesh-toggle" class="mi keep meshtoggle" aria-expanded="false" aria-controls="exp-mesh" title="Units, up axis and mesh density for STL, 3MF, AMF, OBJ, GLB and GLTF"><i data-icon="right" data-size="14" data-stroke="2"></i><span>Mesh settings</span><span id="exp-mesh-sum" class="k">Auto</span></button>+ <div id="exp-mesh" hidden>+ <div class="expopts">+ <span>Units</span><div id="exp-units" class="seg" aria-label="Units of mesh files"><button data-v="" title="GLB and GLTF in meters, the other formats in millimeters">Auto</button><button data-v="mm">mm</button><button data-v="m">m</button></div>+ <span>Up</span><div id="exp-up" class="seg" aria-label="Axis pointing up in mesh files"><button data-v="" title="GLB and GLTF with Y up, the other formats with Z up as in the model">Auto</button><button data-v="z">Z</button><button data-v="y">Y</button></div>+ <span>Detail</span><div id="exp-detail" class="seg" aria-label="Mesh density"><button data-v="coarse" title="Fewer triangles, for example for game engines">Coarse</button><button data-v="normal">Normal</button><button data-v="fine" title="More triangles, smoother curves">Fine</button></div>+ </div>+ <div class="mnote">For STL, 3MF, AMF, OBJ, GLB and GLTF. Auto: GLB and GLTF in meters with Y up, as game engines and Blender expect them, the others in millimeters with Z up.</div>+ </div><div class="mh">3D PRINTING</div><div class="chips"><button class="chip" data-fmt="stl">STL</button><button class="chip" data-fmt="3mf">3MF</button><button class="chip" data-fmt="amf">AMF</button></div><div class="mh">CAD EXCHANGE</div>diff --git a/app/src/renderer/main.ts b/app/src/renderer/main.tsindex b08f4a5..0fe7b99 100644--- a/app/src/renderer/main.ts+++ b/app/src/renderer/main.ts@@ -1,6 +1,6 @@import { affectsBuild } from '../shared/editable';import { DEFAULT_SETTINGS, type SettingsPatch, type SettingsResult, type SettingsState } from '../shared/settings';-import type { AgentInfo, AnimEntry, BuildStatus, CadQueryImportResult, DrawingEntry, DrawingList, ExportResult, FileNode, ImportResult, ModelMap, PartMap, PreviewResult, ProjectInfo, ProjectListEntry, ResultEntry, SaveState, UpdateInfo } from '../shared/types';+import type { AgentInfo, AnimEntry, BuildStatus, CadQueryImportResult, DrawingEntry, DrawingList, ExportResult, FileNode, ImportResult, MeshExportOptions, ModelMap, PartMap, PreviewResult, ProjectInfo, ProjectListEntry, ResultEntry, SaveState, UpdateInfo } from '../shared/types';import { AnalysisPanel } from './analysispanel';import { AnimPanel, animKey, videoKey } from './animpanel';import { SOMA_VERSION } from '../shared/version';@@ -1478,6 +1478,7 @@ function renderExportScope(): void {function openExportMenu(anchor: HTMLElement = $('btn-export')): void {renderExportScope();const m = $('menu-export');+ if (!menus.isOpen(m)) setMeshOptsOpen(false);if (!menus.isOpen(m)) menus.toggle(m, anchor, anchor.id === 'btn-export' ? 'right' : 'left');}$('btn-export').addEventListener('click', () => {@@ -1490,6 +1491,51 @@ $('btn-sel-export').addEventListener('click', () => {exportScope = 'sel';openExportMenu($('btn-sel-export'));});+// Netz-Einstellungen (Issue #8): gemerkt in diesem Fenster, leer heißt die Vorgabe des Formats in `soma export`+const MESH_OPTS_KEY = 'soma.exportMesh';+let meshOpts: MeshExportOptions = (() => {+ try {+ const o = JSON.parse(store.get(MESH_OPTS_KEY) ?? '{}') as Record<string, unknown>;+ return {+ ...(o.units === 'mm' || o.units === 'm' ? { units: o.units } : {}),+ ...(o.up === 'z' || o.up === 'y' ? { up: o.up } : {}),+ ...(o.detail === 'coarse' || o.detail === 'fine' ? { detail: o.detail } : {}),+ };+ } catch { return {}; }+})();+const MESH_SEGS: [string, keyof MeshExportOptions, string][] = [['exp-units', 'units', ''], ['exp-up', 'up', ''], ['exp-detail', 'detail', 'normal']];+function renderMeshOpts(): void {+ for (const [id, key, dflt] of MESH_SEGS) {+ const cur = meshOpts[key] ?? dflt;+ for (const b of $(id).querySelectorAll<HTMLButtonElement>('button')) {+ b.classList.toggle('on', b.dataset.v === cur);+ b.setAttribute('aria-pressed', String(b.dataset.v === cur));+ }+ }+ // Zugeklappt zeigt die Zeile, was vom Normalfall abweicht, damit eine Einstellung von früher nicht übersehen wird+ const { units, up, detail } = meshOpts;+ const sum = [units, up && `${up.toUpperCase()} up`, detail && detail[0].toUpperCase() + detail.slice(1)].filter(Boolean).join(' · ');+ $('exp-mesh-sum').textContent = sum || 'Auto';+}+/** Netz-Einstellungen auf- oder zuklappen. Normalerweise braucht man sie nicht, deshalb startet das Menü zugeklappt. */+function setMeshOptsOpen(open: boolean): void {+ $('exp-mesh').hidden = !open;+ $('exp-mesh-toggle').setAttribute('aria-expanded', String(open));+}+$('exp-mesh-toggle').addEventListener('click', () => setMeshOptsOpen($('exp-mesh').hidden));+for (const [id, key, dflt] of MESH_SEGS) {+ $(id).addEventListener('click', (ev) => {+ const b = (ev.target as HTMLElement).closest<HTMLButtonElement>('button[data-v]');+ if (!b) return;+ const v = b.dataset.v ?? '';+ const next: Record<string, string> = { ...meshOpts };+ if (v && v !== dflt) next[key] = v; else delete next[key];+ meshOpts = next as MeshExportOptions;+ store.set(MESH_OPTS_KEY, JSON.stringify(meshOpts));+ renderMeshOpts();+ });+}+renderMeshOpts();$('exp-all').addEventListener('click', () => { exportScope = 'all'; renderExportScope(); });$('exp-sel').addEventListener('click', () => { exportScope = 'sel'; renderExportScope(); });document.querySelectorAll<HTMLButtonElement>('#menu-export [data-fmt]').forEach((b) => b.addEventListener('click', () => void doExport(b.dataset.fmt!, b.textContent!)));@@ -1528,11 +1574,13 @@ async function doExport(fmt: string, label: string): Promise<ExportResult> {menus.close();const e = selection ? partEntry(selection.partId) : undefined;const part = exportScope === 'sel' ? e?.name ?? partInfo(selection?.partId ?? '')?.name ?? null : null;- const r = await api.build.export(fmt, part);+ const r = await api.build.export(fmt, part, meshOpts);if (r.cancelled) return r;const name = (f: string) => f.split(/[\\/]/).pop() ?? f;- if (r.ok && part) toast(`“${part}” exported as ${label}:\n${r.target ?? r.files[0] ?? ''}`);- else if (r.ok) toast(`${r.files.length} file${r.files.length === 1 ? '' : 's'} exported as ${label} to ${r.target ?? ''}:\n${r.files.map(name).join(', ') || '(no file)'}`);+ // Hinweise von soma (Netz nicht geschlossen, welche Flächen) gehören dazu: Bericht statt stiller Reparatur (E28)+ const warn = r.warnings?.length ? `\n${r.warnings.join('\n')}` : '';+ if (r.ok && part) toast(`“${part}” exported as ${label}:\n${r.target ?? r.files[0] ?? ''}${warn}`, warn ? 'error' : 'ok');+ else if (r.ok) toast(`${r.files.length} file${r.files.length === 1 ? '' : 's'} exported as ${label} to ${r.target ?? ''}:\n${r.files.map(name).join(', ') || '(no file)'}${warn}`, warn ? 'error' : 'ok');else toast(`Export failed: ${r.error}`, 'error');return r;}diff --git a/app/src/renderer/style.css b/app/src/renderer/style.cssindex fff04f3..90f22ef 100644--- a/app/src/renderer/style.css+++ b/app/src/renderer/style.css@@ -949,6 +949,14 @@ code { font-family:var(--mono); font-size:.95em; }.seg { display:flex; margin:2px 10px 8px; border:1px solid var(--line2); border-radius:7px; overflow:hidden; }.seg button { flex:1; height:28px; font-size:12px; color:var(--tx2); padding:0 8px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }.seg button.on { background:var(--s3); color:var(--tx); font-weight:500; }+/* Netz-Einstellungen im Export-Menü: zugeklappt nur eine Zeile mit Zusammenfassung, aufgeklappt Beschriftung links,+ Umschalter rechts */+.meshtoggle > svg.ic { transition:transform .15s; }+.meshtoggle[aria-expanded=true] > svg.ic { transform:rotate(90deg); }+.expopts { display:grid; grid-template-columns:auto 1fr; align-items:center; gap:4px 10px; padding:0 10px 4px; }+.expopts > span { color:var(--tx2); font-size:12px; }+.expopts .seg { margin:0; }+.expopts .seg button { height:22px; font-size:12px; }.seg button:disabled { color:#5d6671; }.chips { display:flex; flex-wrap:wrap; gap:6px; padding:2px 10px 8px; }.chip { height:28px; padding:0 10px; border:1px solid var(--line2); border-radius:6px; font-size:12px; }diff --git a/app/src/shared/types.ts b/app/src/shared/types.tsindex 5a2c13a..cf40e84 100644--- a/app/src/shared/types.ts+++ b/app/src/shared/types.ts@@ -73,6 +73,12 @@ export interface BuildStatus {* Export über einen Dateidialog. `files`: geschriebene Dateien mit absolutem Pfad, `target`: gewählte Datei oder gewählter* Ordner. `cancelled`: Dialog oder Rückfrage abgebrochen, nichts geschrieben.*/+/**+ * Einstellungen für Netzformate (STL, 3MF, AMF, OBJ, GLB, GLTF) beim Export, Issue #8. Fehlt ein Wert, gilt die Vorgabe des+ * Formats in `soma export`: GLB/GLTF in Metern mit Y nach oben, alles andere in mm mit Z nach oben.+ */+export interface MeshExportOptions { units?: 'mm' | 'm'; up?: 'z' | 'y'; detail?: 'coarse' | 'normal' | 'fine' }+export interface ExportResult { ok: boolean; files: string[]; target?: string; cancelled?: boolean; error?: string; warnings?: string[] }/** Neues Modell aus einem CadQuery-Skript (E100). `info`: das geöffnete Modell, `warnings`: Hinweise des Imports. */export interface CadQueryImportResult { info?: ProjectInfo; warnings: string[]; cancelled?: boolean; error?: string }@@ -482,8 +488,8 @@ export interface SomaApi {setAuto(on: boolean): Promise<void>;status(): Promise<BuildStatus>;onStatus(cb: (s: BuildStatus) => void): void;- /** `part` null = alle Bauteile ohne Referenzen. */- export(format: string, part: string | null): Promise<ExportResult>;+ /** `part` null = alle Bauteile ohne Referenzen. `mesh` gilt nur für Netzformate, bei anderen ignoriert. */+ export(format: string, part: string | null, mesh?: MeshExportOptions): Promise<ExportResult>;};fs: {list(): Promise<FileNode[]>;diff --git a/app/test/helpshots-spec.mjs b/app/test/helpshots-spec.mjsindex c8d657c..5944780 100644--- a/app/test/helpshots-spec.mjs+++ b/app/test/helpshots-spec.mjs@@ -128,6 +128,7 @@ export const SHOTS = [pad: 28,marks: [{ label: 'Scope', sel: '#menu-export .seg', at: 'l' },+ { label: 'Mesh settings', sel: '#exp-mesh-toggle', at: 'l' },{ label: 'Formats', sel: '#menu-export .chips', at: 'l', box: true },{ label: 'Everything as ZIP', sel: '#exp-zip', at: 'l' },{ label: 'As CadQuery script', sel: '#exp-cq', at: 'l' },diff --git a/app/test/meshexport.mjs b/app/test/meshexport.mjsindex b2d3b92..04602c9 100644--- a/app/test/meshexport.mjs+++ b/app/test/meshexport.mjs@@ -201,6 +201,72 @@ try {fs.writeFileSync(path.join(open, 'model.py'), 'import cadquery as cq\nfrom soma import add_part\nadd_part("Sheet", cq.Workplane().box(10, 10, 10).faces(">Z").val())\n');const o = soma(['export', 'Sheet', '--format', '3mf', '--project', open, '--out', path.join(work, 'out-open')]);check('Offene Fläche: exportiert mit Warnung zu offenen Kanten', o.status === 0 && /exported: /.test(o.stdout) && /warning: mesh of 'Sheet' is not closed: \d+ open edge/.test(o.stdout), (o.stdout + o.stderr).slice(-200));++ // Netz-Optionen (Issue #8): Einheit, Achse nach oben, Detailstufe. Ein Quader 100 x 50 x 20 mm, unten auf z = 0, mit+ // eigenem Leser geprüft: Ausdehnung je Achse in der Zieleinheit, glTF standardmäßig in Metern mit Y nach oben+ const opt = path.join(work, 'opts');+ fs.mkdirSync(opt);+ fs.writeFileSync(path.join(opt, 'model.py'), 'import cadquery as cq\nfrom soma import add_part\nadd_part("Box", cq.Workplane().box(100, 50, 20).translate((0, 0, 10)).edges().fillet(3))\n');+ const runs = [+ ['glb', []], ['gltf', ['--units', 'mm', '--up', 'z']], ['stl', ['--units', 'm', '--up', 'y']], ['3mf', ['--units', 'in']],+ ['obj', ['--detail', 'coarse']], ['amf', ['--detail', 'fine']],+ ];+ for (const [fmt, extra] of runs) {+ const r = soma(['export', 'Box', '--format', fmt, ...extra, '--project', opt, '--out', path.join(work, 'out-opts')]);+ check(`Optionen: ${fmt} ${extra.join(' ')} exportiert`, r.status === 0 && /exported: /.test(r.stdout), (r.stdout + r.stderr).slice(-200));+ }+ const bounds = spawnSync(PY, ['-c', String.raw`+import json, re, struct, sys, zipfile+from pathlib import Path+import numpy as np+d = Path(sys.argv[1]); out = {}+def box(p): p = np.asarray(p, float); return [p.min(0).round(4).tolist(), p.max(0).round(4).tolist()]+for ext in ("glb", "gltf"):+ f = d / f"Box.{ext}"+ if ext == "glb":+ b = f.read_bytes(); n = struct.unpack("<I", b[12:16])[0]; g = json.loads(b[20:20 + n])+ else:+ g = json.loads(f.read_text())+ acc = [a for a in g["accessors"] if "min" in a and len(a["min"]) == 3]+ out[ext] = [np.min([a["min"] for a in acc], 0).round(4).tolist(), np.max([a["max"] for a in acc], 0).round(4).tolist()]+ out[ext + "_prims"] = sum(len(m["primitives"]) for m in g["meshes"])+r = (d / "Box.stl").read_bytes()+v = np.frombuffer(r[84:], dtype=np.dtype([("n", "<f4", 3), ("v", "<f4", (3, 3)), ("a", "<u2")]))+out["stl"] = box(v["v"].reshape(-1, 3))+m = zipfile.ZipFile(d / "Box.3mf").read("3D/3dmodel.model").decode()+out["3mf_unit"] = re.search(r'<model unit="(\w+)"', m)[1]+out["3mf"] = box([[float(x) for x in t] for t in re.findall(r'<vertex x="([-\d.e]+)" y="([-\d.e]+)" z="([-\d.e]+)"', m)])+o = (d / "Box.obj").read_text()+out["obj_tris"] = o.count("\nf ")+a = (d / "Box.amf").read_text()+out["amf_tris"] = a.count("<triangle>")+print(json.dumps(out))+`, path.join(work, 'out-opts')], { encoding: 'utf8', env: ENV });+ const B = bounds.status === 0 ? JSON.parse(bounds.stdout) : {};+ const near = (a, b) => Array.isArray(a) && a.flat().every((x, i) => Math.abs(x - b.flat()[i]) < 1e-3 * Math.max(1, Math.abs(b.flat()[i])));+ check('GLB ohne Optionen: Meter, Y nach oben, eine Primitive', near(B.glb, [[-0.05, 0, -0.025], [0.05, 0.02, 0.025]]) && B.glb_prims === 1, JSON.stringify([B.glb, B.glb_prims, bounds.stderr.slice(-200)]));+ check('GLTF mit --units mm --up z: mm, Z nach oben', near(B.gltf, [[-50, -25, 0], [50, 25, 20]]), JSON.stringify(B.gltf));+ check('STL mit --units m --up y: Meter, Y nach oben', near(B.stl, [[-0.05, 0, -0.025], [0.05, 0.02, 0.025]]), JSON.stringify(B.stl));+ check('3MF mit --units in: Einheit inch, Koordinaten in Zoll', B['3mf_unit'] === 'inch' && near(B['3mf'], [[-50 / 25.4, -25 / 25.4, 0], [50 / 25.4, 25 / 25.4, 20 / 25.4]]), JSON.stringify([B['3mf_unit'], B['3mf']]));+ check('Detail: coarse hat weniger Dreiecke als fine', B.obj_tris > 0 && B.obj_tris < B.amf_tris, `coarse ${B.obj_tris}, fine ${B.amf_tris}`);+ const badAmf = soma(['export', 'Box', '--format', 'amf', '--units', 'cm', '--project', opt, '--out', path.join(work, 'out-opts')]);+ check('AMF mit cm: verständlicher Fehler', badAmf.status === 2 && /AMF does not support the unit 'cm'/.test(badAmf.stderr), badAmf.stderr.slice(-200));+ const badStep = soma(['export', 'Box', '--format', 'step', '--up', 'y', '--project', opt, '--out', path.join(work, 'out-opts')]);+ check('STEP mit --up: Fehler, nur für Netzformate', badStep.status === 2 && /--up only apply to mesh formats/.test(badStep.stderr), badStep.stderr.slice(-200));++ // Nicht vernetzte Flächen: Die Warnung nennt Art, Fläche und Lage, winzige als Splitter (Issue #10). Eine Fläche, an der+ // OCC sicher scheitert, lässt sich nicht gezielt bauen, deshalb mit einem Körper, dem eine echte Splitterfläche fehlt.+ const miss = spawnSync(PY, ['-c', String.raw`+import cadquery as cq+from soma import meshexport as m+sliver = cq.Workplane().center(42.6, 24).rect(0.05, 0.02).extrude(1).faces("<Z").val()+box = cq.Workplane().box(10, 10, 10).val()+b = dict(m.body_meshes(box, "Case")[0], missing_faces=7, missing=[m._face_info(sliver)] + [m._face_info(box.Faces()[0])] * 5 + [None])+print(m.problems([b])[0])+`], { encoding: 'utf8', env: ENV });+ check('Nicht vernetzte Flächen: Warnung mit Art, Fläche, Lage und Splitter-Hinweis',+ miss.status === 0 && miss.stdout.includes("7 face(s) could not be meshed (PLANE, 0.001 mm², probably a sliver at x 42.6, y 24.0, z 0.0; PLANE, 100.0 mm² at x ")+ && miss.stdout.includes('; and 2 more)'), (miss.stdout + miss.stderr).slice(-300));} catch (e) {check('Ablauf ohne Ausnahme', false, String(e?.stack ?? e).slice(0, 300));} finally {diff --git a/app/test/smoke.mjs b/app/test/smoke.mjsindex dfa4fc3..da2eb63 100644--- a/app/test/smoke.mjs+++ b/app/test/smoke.mjs@@ -93,6 +93,14 @@ try {const expDir = fs.mkdtempSync(path.join(os.tmpdir(), 'soma-export-test-'));await domClick('btn-sel-export');const expMenu = await ev(() => ({ open: !document.getElementById('menu-export').hidden, sel: document.getElementById('exp-sel').classList.contains('on') ? document.getElementById('exp-sel').textContent : '' }));+ // Netz-Einstellungen (Issue #8): zugeklappt, ein Klick klappt auf, ohne das Menü zu schließen, die Zeile fasst zusammen+ const meshClosed = await ev(() => ({ hidden: document.getElementById('exp-mesh').hidden, sum: document.getElementById('exp-mesh-sum').textContent }));+ await domClick('exp-mesh-toggle');+ await ev(() => document.querySelector('#exp-up [data-v="y"]').click());+ const meshOpen = await ev(() => ({ menu: !document.getElementById('menu-export').hidden, hidden: document.getElementById('exp-mesh').hidden, sum: document.getElementById('exp-mesh-sum').textContent }));+ await ev(() => document.querySelector('#exp-up [data-v=""]').click());+ check('Export-Menü: Netz-Einstellungen zugeklappt, aufklappbar, Zusammenfassung „Y up“', meshClosed.hidden && meshClosed.sum === 'Auto' && meshOpen.menu && !meshOpen.hidden && meshOpen.sum === 'Y up'+ && await ev(() => document.getElementById('exp-mesh-sum').textContent) === 'Auto', JSON.stringify([meshClosed, meshOpen]));await ev(() => document.body.dispatchEvent(new KeyboardEvent('keydown', { key: 'Escape', bubbles: true })));await app.answers([path.join(expDir, 'Deckel.step')]);const one = await ev(() => window.__t.exportAs('step', 'sel'));