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: Skill Technical drawings, Test drawing, .soma/drawings als Zwischenstand (E76)
Kai-Jungsthoefel49368ad47b5d
diff --git a/app/package.json b/app/package.jsonindex de0fa4d..521733d 100644--- a/app/package.json+++ b/app/package.json@@ -19,6 +19,7 @@"test:skills": "npm run build && node test/skills.mjs","test:params": "npm run build && node test/params.mjs","test:fasteners": "npm run build && node test/fasteners.mjs",+ "test:drawing": "npm run build && node test/drawing.mjs","test:animation": "npm run build && node test/animation.mjs","test:packages": "npm run build && node test/packages.mjs","test:unit": "node test/unit.mjs",diff --git a/app/resources/skills/zeichnung.md b/app/resources/skills/zeichnung.mdnew file mode 100644index 0000000..47f574b--- /dev/null+++ b/app/resources/skills/zeichnung.md@@ -0,0 +1,145 @@+---+title: Technical drawings+name: Technical drawings+summary: Drawings in drawings/*.py to {{standard}}: views, sections, details and dimensions measured from the model, as PDF and DXF.+order: 33+category: Check and present+default: on-demand+when: the user wants a technical drawing, a manufacturing or assembly drawing, a PDF or DXF with dimensions, or a parts list+topics: Before drawing; Sheet and views; Sections and details; Dimensions; Tolerances and notes; Assembly drawings; Free drawing; Build and check; Feedback+var standard: ISO | | Standard | ISO=ISO (first angle projection), ASME=ASME (third angle projection)+var size: A3 | | Usual sheet size | A4, A3, A2, A1, A0+var tolerance: ISO 2768-m | | General tolerances | ISO 2768-f=ISO 2768-f (fine), ISO 2768-m=ISO 2768-m (medium), ISO 2768-c=ISO 2768-c (coarse), none=none+var language: en | | Language on the drawing | en=English, de=German+---+# Skill: Technical drawings++A drawing is Python in `drawings/<name>.py`. You decide what goes where. soma projects the model (visible and+hidden edges), cuts sections, measures every dimension from the geometry and writes PDF and DXF. For this model:+standard {{standard}}, sheet {{size}}, general tolerances {{tolerance}}, texts on the drawing in language+"{{language}}". Do not change `model.py` for a drawing.++```python+from soma.drawing import Sheet+from model import L, W, T, HOLE # the model's constants (add_part has no effect here)++sh = Sheet("Bracket", size="{{size}}", scale="1:2", number="BR-001", material="AlMg3",+ tolerance="{{tolerance}}", projection="first", language="{{language}}")+front = sh.view("Bracket", "front", at=(140, 190)) # at: sheet point (mm) for the middle of the part+top = sh.view("Bracket", "top", at=(140, 95)) # same x: lined up under the front view+a = sh.section("Bracket", "left", through=(0, 0, 0), at=(300, 190), name="A", parent=front)+b = sh.detail(front, (20, 0, T), 4, at=(330, 80), scale="5:1", name="B")+top.dim((-L / 2, -W / 2, T), (L / 2, -W / 2, T), offset=-10) # model points on an edge; soma measures+top.diameter((45, 17.5, T), HOLE / 2, text="4x <>")+top.center_marks()+sh.text("Deburr all edges", (30, 30))+```++## Before drawing++- Ask what the drawing is for: making a part (workshop, supplier), assembly, inspection. A part that is only laser or+ water-jet cut needs a 1:1 DXF of its outline, not a drawing (skill for laser cutting).+- Plan first and write the plan as comments at the top of the file: sheet and scale, views, sections, details, the+ dimensions per view and their datums.+- One part per sheet for manufacturing drawings, the assembly on a sheet of its own. Several `Sheet(...)` per file are+ fine, names are unique.+- Dimensions follow the function: which faces mate, which holes line up, which edge is the datum. Ask the user when+ it is not clear from the model or `NOTES.md`.++## Sheet and views++- The smallest sheet on which views and dimensions fit with room. Scales of ISO 5455: 1:1, 1:2, 1:5, 1:10, 2:1, 5:1,+ 10:1. Text stays 3.5 mm at any scale.+- Front view: the view that shows most of the shape, in the position of use or of machining. As few views as needed:+ often front and top or front and side, a turned part needs one view with Ø.+- ISO uses first angle projection (`projection="first"`): top view below the front view, the view from the left to+ its right. ASME uses third angle (`projection="third"`): top view above, the view from the right to its right. A+ row of views shares x (column) or y (row) of `at`. The default origin is the middle of the part, so views of the+ same parts line up.+- 15 to 25 mm between views for dimensions. Everything stays inside the frame and off the title block:+ `soma drawing info` prints the drawing area.+- Hidden edges (`hidden=`, on in the six standard views) only where they explain something. A section is clearer.+ Iso views without hidden edges and without dimensions, smaller, top right.+- `what` is a part, a group, a list, `"*"` or any CadQuery shape built in the drawing file: `sh.shape("Housing")` gives+ the geometry to cut, move or simplify first.+- `direction` can be a vector from the part to the viewer (auxiliary view of an inclined face), `up=` turns the view.+- `style="phantom"`: adjacent parts and extreme positions as thin dash-double-dot lines. Give it the same `origin=`+ (a model point) and `at=` as the view it belongs to.++## Sections and details++- Section where inner shape matters: bores, pockets, walls. `sh.section(what, direction, through=point, ...)` removes+ everything between the viewer and the plane through `point`. `name="A"` with `parent=front` draws the cutting line,+ arrows and letters, and "A-A" above the section.+- Half section of a symmetric part or a local break-out: `region=` a solid that is removed (a box over one quarter).+ Draw the border yourself: center line for a half section, thin freehand line for a break-out.+- Not cut along their axis (ISO 128-40): screws, nuts, washers, pins, shafts, keys, rolling elements, ribs. List them+ in `unhatched=`.+- Hatching is 45° and alternates between neighbouring parts. Thin walls (under 2 mm on the sheet): `hatch="solid"`.+- Details for small features (grooves, chamfers, undercuts): `sh.detail(parent, center, radius, at, scale, name="B")`,+ usually 2:1 to 10:1.++## Dimensions++- Never type a value: give model points, soma measures. `"<>"` in `text` is the measured value: `"Ø<> H7"`,+ `"<> ±0.1"`, `"4x <>"`, `"(<>)"` for an auxiliary dimension. Typed numbers that differ from the model are reported.+- Every feature is dimensioned once, in the view where it shows best. Dimension visible edges, not hidden ones. Points+ lie on an edge or on a circle center of that view: on rounded or chamfered corners take a point on the straight+ edge, not the virtual corner.+- Functional dimensions first. Hole positions that matter from one datum (baseline), chains only where the function+ is a chain. Never close a chain: leave one out or make it auxiliary.+- Small dimensions near the part, bigger ones outside: first line about 10 mm from the edge, then 7 to 8 mm steps+ (`offset`). Dimension lines do not cross each other, texts never sit on edges.+- Diameters with `view.diameter(center, r)` where the hole is a circle, on a side view a linear dimension with+ `"Ø<>"`. Radii with `view.radius(center, r)`. Patterns: one dimension `"4x <>"`, positions from a datum or the+ pattern center, `view.center_marks()`.+- Threads: `"M5"` or `"M5 - 10 deep"` on the hole. soma models threads without the helix (tap drill or core), so+ always name the thread. Through holes: `"Ø<> THRU"` or a leader.+- Angles: `view.angle(vertex, p1, p2)` in views where both lines lie in the paper plane.+- `view.circles()` and `soma drawing info` list the circle centers and diameters per view: use them for hole+ positions instead of guessing.++## Tolerances and notes++- The general tolerance stands in the title block. Single tolerances only where the function needs them: `tol=0.1`,+ `tol=(0.1, -0.05)`, fits `"Ø<> H7"` on holes and `"Ø<> g6"` on shafts. The skill for tolerances helps choose.+- Surface roughness (`Ra 1.6`) and geometrical tolerances only where needed: a leader with text, or draw the symbol+ with ezdxf.+- Notes above the title block or bottom left: "Deburr all edges", "Break sharp edges 0.3 x 45°", heat treatment.+- Title block: `number`, `material`, `author`, `owner`, `revision`, `tolerance`. Take company and drawing number from+ `NOTES.md` or ask the user, do not invent them. With `titleblock=False` you draw your own.++## Assembly drawings++- Views of the assembly, often a section along the main axis with the screws unhatched. Only overall, connecting and+ fitting dimensions.+- Item numbers with `view.leader(point_on_part, "1", at=..., end="dot")`, lined up in a row or column, the same part+ always gets the same number.+- Parts list with `sh.table(rows, at, widths)` on the title block: item, name, quantity, material or designation (for+ standard parts the designation of `soma.fasteners`, e.g. "ISO 4762 M5x16").++## Free drawing++- `sh.msp` is the ezdxf model space in sheet millimetres: lines, arcs, polylines, hatches, texts, blocks. Layers+ VISIBLE (0.5 mm), THIN, CENTER, HIDDEN, PHANTOM, HATCH, CUT, DIM, TEXT, text style and dimension style "ISO". Own+ ezdxf dimensions in a view need `override={"dimlfac": 1 / view.scale}`.+- `view.pt((x, y, z))` is the sheet point of a model point. Draw what soma does not offer yourself: surface and weld+ symbols, datum triangles, break lines, a different title block.+- `sh.text(text, at, height=3.5, align=, rotation=)`, several lines with `\n`. Heights: 3.5 mm, view names 5 mm,+ never under 2.5 mm.++## Build and check++1. `soma drawing build` (or `soma drawing build drawings/x.py`). Errors name file and line. Warnings report texts on+ edges or on each other, things outside the frame or on the title block, points on no edge, typed numbers that+ differ from the model and uncommon scales. Fix them, or tell the user why one is fine.+2. **Open the picture `.soma/drawings/<name>.png` and look at it.** It is large and gets scaled down when you open it:+ crop parts of it (Pillow is installed) to read small texts and check every dimension and hatching.+3. `soma drawing info "Name"`: views with their place on the sheet, circles, every dimension with its value. Compare+ with your plan: every feature dimensioned once, nothing crowded.+4. PDF and DXF are in `output/drawings/`. After model changes build the drawings again before you commit.++## Feedback++The user opens the PDF in the app and marks it up: `[Markup: .soma/feedback/... , drawn on output/drawings/x.pdf p. 1]`+shows what to change. Open the picture, change the drawing file (never the PDF) and build again.diff --git a/app/resources/template/.gitignore b/app/resources/template/.gitignoreindex 52f0c4a..2b9b259 100644--- a/app/resources/template/.gitignore+++ b/app/resources/template/.gitignore@@ -13,10 +13,11 @@ __pycache__/.soma/feedback/.soma/geometry/-# Pictures and videos from soma render, built animations and analysis results (regenerated from the code)+# Pictures and videos from soma render, built animations, analysis results and drawing previews (regenerated from the code)renders/.soma/anim/.soma/results/+.soma/drawings/# Environment with the model's extra packages (only requirements.txt is versioned).soma/env/diff --git a/app/resources/template/AGENTS.md b/app/resources/template/AGENTS.mdindex 84a7be6..074956a 100644--- a/app/resources/template/AGENTS.md+++ b/app/resources/template/AGENTS.md@@ -16,8 +16,9 @@ The app shows the result in a 3D viewer next to this terminal. Notes and wishes| `exports/` | Single-part exports written by `soma export` || `animations/` | Optional. Motion, camera flights and captions in Python (`soma.anim`), one file per topic. The skill for animation explains them || `analyses/` | Optional. Load cases for `soma analyze fem` in Python (`soma.fem`), one file per load case. The skill for FEM explains them |+| `drawings/` | Optional. Technical drawings in Python (`soma.drawing`), one file per drawing or set of sheets. `soma drawing build` writes PDF and DXF to `output/drawings/`. The skill for technical drawings explains them || `renders/` | Pictures and videos written by `soma render`. Not in the version history and not in the saved ZIP |-| `.soma/` | App data (viewer cache, build status, feedback images, skills, built animations, analysis results). Do not edit. Read the skills in `.soma/skills/` as the list at the end of this file says, and files in `.soma/feedback/` when the user points you to them |+| `.soma/` | App data (viewer cache, build status, feedback images, skills, built animations, analysis results, drawing pictures). Do not edit. Read the skills in `.soma/skills/` as the list at the end of this file says, and files in `.soma/feedback/` when the user points you to them |## Rules for model.py@@ -44,6 +45,7 @@ Run them in this terminal. They work without the app.| `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 || `soma anim build`, `soma anim info "Name"` | Animations from `animations/`. Details in the skill for animation |+| `soma drawing build`, `soma drawing info "Name"` | Technical drawings from `drawings/` as PDF, DXF and a picture to check. Details in the skill for technical drawings |If `soma build` fails, fix the error before doing anything else. Keep the model buildable at all times.diff --git a/app/src/main/git.ts b/app/src/main/git.tsindex 3764388..abb82df 100644--- a/app/src/main/git.ts+++ b/app/src/main/git.ts@@ -24,7 +24,7 @@ const COMMON = ['-c', 'core.quotepath=false', '-c', 'core.autocrlf=false'];* nicht in der .gitignore, deshalb klammert die App sie selbst aus, beim Status und beim Hinzufügen (siehe addAll), und* trägt sie beim Öffnen in .git/info/exclude ein, damit auch die Commits des Agenten sie nicht aufnehmen (ensureIgnored).*/-const APP_CACHES = ['.soma/geometry', '.soma/anim', '.soma/results', '.soma/env', 'renders'];+const APP_CACHES = ['.soma/geometry', '.soma/anim', '.soma/results', '.soma/drawings', '.soma/env', 'renders'];/** `output/` zählt nicht als Änderung: STEP-Dateien sind nicht byte-stabil (Zeitstempel, teils Reihenfolge). */const NOT_OUTPUT = ['--', '.', ':(exclude)output', ...APP_CACHES.map((p) => `:(exclude)${p}`)];/** Was die Vorlage in der .gitignore hat (resources/template/.gitignore), für ältere Projekte in .git/info/exclude. */diff --git a/app/src/main/workspace.ts b/app/src/main/workspace.tsindex 7838860..576584f 100644--- a/app/src/main/workspace.ts+++ b/app/src/main/workspace.ts@@ -242,7 +242,7 @@ export async function backupWorkspace(id: string): Promise<string> {* Ordner, die Git nicht sieht (in der .gitignore), in denen aber Eigenes des Nutzers liegen kann: Markierungen, Bilder und* Videos von `soma render`, Ergebnisse, gebaute Animationen.*/-const UNTRACKED_CONTENT = ['.soma/feedback', 'renders', '.soma/results', '.soma/anim'];+const UNTRACKED_CONTENT = ['.soma/feedback', 'renders', '.soma/results', '.soma/anim', '.soma/drawings'];const hasFiles = (dir: string): boolean => {try { return fs.readdirSync(dir).length > 0; } catch { return false; }diff --git a/app/src/main/zip.ts b/app/src/main/zip.tsindex 2ab9bb0..e64adea 100644--- a/app/src/main/zip.ts+++ b/app/src/main/zip.ts@@ -17,7 +17,7 @@ const SKIP_FILES = new Set(['.soma/model.glb', '.soma/model.map.json', '.soma/bu* Die Projektumgebung (E67) legt die App beim Öffnen an und installiert dabei requirements.txt. Bilder und Videos von* soma render entstehen aus dem Code neu (E75, beim Hotwire 41 % der ZIP).*/-const SKIP_PATHS = new Set(['.soma/geometry', '.soma/anim', '.soma/results', '.soma/env', 'renders']);+const SKIP_PATHS = new Set(['.soma/geometry', '.soma/anim', '.soma/results', '.soma/drawings', '.soma/env', 'renders']);/** Schon gepackt (Git-Objekte sind zlib, Bilder und Videos komprimiert): nur ablegen, nochmal Deflate kostet nur Zeit. */const STORED = /^\.git\/objects\/|\.(png|jpe?g|webp|mp4|webm|zip|gz|7z|pack)$/i;const MAX_UNPACKED = 2 * 1024 ** 3;diff --git a/app/test/drawing.mjs b/app/test/drawing.mjsnew file mode 100644index 0000000..09e7814--- /dev/null+++ b/app/test/drawing.mjs@@ -0,0 +1,187 @@+// Test für technische Zeichnungen (soma.drawing, E76): Der Codeblock des Skills „Technical drawings“ baut ohne Hinweise,+// Ansichten, Schnitt, Einzelheit und Maße landen als DXF, PDF und PNG, gleicher Inhalt gibt gleiche Dateien, die Prüfung+// meldet getippte Zahlen, Punkte neben Kanten, verdeckte Kanten, Text außerhalb und übereinander, Fehler nennen Datei und+// Zeile. Dann in der echten App: die PDF öffnet im Code-Panel, Bild und PDF zählen nicht als ungespeicherte Änderung.+// Aufruf: npm run test:drawing (baut vorher). SMOKE_VISIBLE=offscreen SMOKE_SHOTS=1 legt ein Bild ab.+import { spawnSync } from 'node:child_process';+import fs from 'node:fs';+import os from 'node:os';+import path from 'node:path';+import { APP, checker, cleanup, sleep, startApp } from './harness.mjs';++const t = checker();+const { check } = t;+let app;++const PY = process.env.SOMA_PYTHON || path.join(process.env.LOCALAPPDATA ?? '', 'cadide-phase0', 'venv-full', 'Scripts', 'python.exe');+const py = (args, opts = {}) => spawnSync(PY, args, { encoding: 'utf8', env: { ...process.env, PYTHONUTF8: '1', PYTHONIOENCODING: 'utf-8' }, ...opts });+const soma = (dir, ...args) => py(['-m', 'soma', ...args, '--project', dir]);++// Passt zum Codeblock des Skills: Platte L x 60 x T mit vier Bohrungen, dazu ein Bolzen für den Schnitt mit ungeschnittenem Teil+const MODEL = `import cadquery as cq+from soma import add_part++L, W, T, HOLE = 120, 60, 12, 8+plate = (cq.Workplane("XY").box(L, W, T, centered=(True, True, False))+ .faces(">Z").workplane().rarray(90, 35, 2, 2).hole(HOLE)+ .faces(">Z").workplane().hole(10))+add_part("Bracket", plate)+add_part("Pin", cq.Workplane("XY").circle(5).extrude(30).translate((0, 0, -9)))+`;++// Absichtlich fehlerhafte Zeichnung: Jede Zeile löst genau eine Art Hinweis aus+const CHECKS = `from soma.drawing import Sheet+sh = Sheet("Checks", size="A3", scale="1:3")+front = sh.view(["Bracket", "Pin"], "front", at=(150, 200))+front.dim((-60, 0, 0), (60, 0, 0), offset=-10, text="125")+front.dim((-60, 0, 0), (-30, 0, 5), offset=-10)+front.dim((-41, 0, 6), (41, 0, 6), offset=-20)+sh.text("outside", (500, 100))+sh.text("one", (40, 40))+sh.text("one again", (41, 40.5))+sh.text("tiny", (40, 60), height=1.5)+cut = sh.section(["Bracket", "Pin"], "front", through=(0, 0, 0), at=(150, 120), name="A", unhatched=["Pin"])+b = sh.detail(front, (60, 0, 12), 5, at=(320, 120), scale="5:1", name="B")+`;++const BROKEN = `from soma.drawing import Sheet+sh = Sheet("Broken")+sh.view("Brackett", "front", at=(100, 100))+`;++let dir;+try {+ // 1) soma drawing ohne App+ dir = fs.mkdtempSync(path.join(os.tmpdir(), 'soma-drawing-'));+ fs.mkdirSync(path.join(dir, 'drawings'));+ fs.writeFileSync(path.join(dir, 'model.py'), MODEL);+ const skill = fs.readFileSync(path.join(APP, 'resources', 'skills', 'zeichnung.md'), 'utf8');+ // Platzhalter mit den Standardwerten aus dem Kopf, wie die App sie in die Kopie schreibt+ const defaults = Object.fromEntries([...skill.matchAll(/^var (\w+): ([^|]*?) \|/gm)].map((m) => [m[1], m[2].trim()]));+ const block = (/```python\r?\n([\s\S]*?)\r?\n```/.exec(skill)?.[1] ?? '').replace(/\{\{(\w+)\}\}/g, (all, k) => defaults[k] ?? all);+ fs.writeFileSync(path.join(dir, 'drawings', 'skill.py'), block + '\n');+ fs.writeFileSync(path.join(dir, 'drawings', 'checks.py'), CHECKS);+ fs.writeFileSync(path.join(dir, 'drawings', 'broken.py'), BROKEN);++ const b1 = soma(dir, 'drawing', 'build', '--json');+ let res = null;+ try { res = JSON.parse(b1.stdout); } catch { /* unten gemeldet */ }+ check('soma drawing build --json: zwei Blätter gebaut, ein Fehler, Rückgabe 1', !!res && res.built.length === 2 && res.errors.length === 1 && b1.status === 1,+ (b1.stderr || b1.stdout).slice(-200));+ const by = Object.fromEntries((res?.built ?? []).map((x) => [x.name, x]));+ const br = by.Bracket;+ check('Skill-Codeblock: Blatt "Bracket" mit 4 Ansichten (Vorder-, Draufsicht, Schnitt A-A, Einzelheit B) und ohne Hinweise',+ block.includes('soma.drawing') && br?.views.length === 4 && br.views.map((v) => v.kind).join(',') === 'view,view,section,detail' && br.warnings.length === 0,+ JSON.stringify(br?.warnings ?? res)?.slice(0, 200));+ check('Maße gemessen: 120 (L) und "4x Ø8" am Durchmesser', br?.dims.some((d) => d.label === '120') && br.dims.some((d) => d.label === '"4x Ø8"'),+ br?.dims.map((d) => d.label).join(' '));+ check('Dateien: PDF und DXF in output/drawings/, Bild in .soma/drawings/ (A3, 200 dpi)', ['output/drawings/Bracket.pdf', 'output/drawings/Bracket.dxf', '.soma/drawings/Bracket.png']+ .every((f) => fs.existsSync(path.join(dir, f))) && fs.readFileSync(path.join(dir, 'output/drawings/Bracket.pdf')).subarray(0, 5).toString() === '%PDF-'+ && br.png_size[0] === 3307, JSON.stringify(br?.png_size));+ const draw = br?.views.find((v) => v.name === 'top');+ check('Ansicht von oben kennt die Bohrungen: 4 x Ø8 mit Mitten, Ø10 in der Mitte', draw?.circles.filter((c) => c.diameter === 8 && !c.arc).length === 4+ && draw.circles.some((c) => c.diameter === 10 && c.center.join(',') === '0,0,12'), JSON.stringify(draw?.circles)?.slice(0, 160));++ const w = (by.Checks?.warnings ?? []).map((x) => `${x.line}: ${x.message}`);+ const has = (line, part) => w.some((m) => m.startsWith(`${line}: `) && m.includes(part));+ check('Prüfung: getippte Zahl "125" statt gemessener 120', has(4, 'differs from the measured 120'), w.join(' | ').slice(0, 200));+ check('Prüfung: Punkt (-30, 0, 5) liegt auf keiner Kante', has(5, 'lies on no edge'), w.filter((m) => m.startsWith('5:')).join(' | '));+ check('Prüfung: Maß an verdeckter Kante (Bohrungen in der Vorderansicht)', has(6, 'only on a hidden edge'), w.filter((m) => m.startsWith('6:')).join(' | '));+ check('Prüfung: Text außerhalb des Rahmens, Texte übereinander, Text unter 2.5 mm, Maßstab 1:3', has(7, 'beyond the frame') && has(9, 'overlaps Text "one"')+ && has(10, 'at least 2.5 mm') && has(2, 'Scale 1:3'), w.join(' | ').slice(0, 200));+ check('Keine Hinweise ohne Grund (Schnitt, Einzelheit, Gesamtmaß 120 an echten Kanten)', !w.some((m) => /^(3|11|12): /.test(m)),+ w.filter((m) => /^(3|11|12): /.test(m)).join(' | '));+ const err = res?.errors[0];+ check('Fehler: Datei, Zeile und die vorhandenen Bauteile', err?.file === 'drawings/broken.py' && err.line === 3 && err.message.includes("'Brackett' does not exist")+ && err.message.includes("'Bracket'"), JSON.stringify(err)?.slice(0, 160));++ // DXF: echte Maße, Schraffur nur am geschnittenen Teil, Linien der Einzelheit nur im Kreis+ const dxfCheck = py(['-c', String.raw`+import json, sys, math, ezdxf+from ezdxf import recover+doc, aud = recover.readfile(sys.argv[1])+msp = doc.modelspace()+types = {}+for e in msp:+ types[e.dxftype()] = types.get(e.dxftype(), 0) + 1+layers = sorted(l.dxf.name for l in doc.layers)+ok_detail = True+for e in msp.query("LINE[layer=='VISIBLE']"):+ for p in (e.dxf.start, e.dxf.end):+ if 290 < p.x < 370 and 40 < p.y < 120 and math.hypot(p.x - 330, p.y - 80) > 20.01:+ ok_detail = False+print(json.dumps(dict(errors=len(aud.errors), types=types, layers=layers, detail=ok_detail, hatches=len(msp.query("HATCH")))))+`, path.join(dir, 'output', 'drawings', 'Bracket.dxf')]);+ let dx = null;+ try { dx = JSON.parse(dxfCheck.stdout); } catch { /* unten */ }+ check('DXF ohne Fehler: 2 Maße als DIMENSION, Schraffur, Layer nach ISO 128', dx?.errors === 0 && dx.types.DIMENSION === 2 && dx.hatches >= 1+ && ['VISIBLE', 'HIDDEN', 'CENTER', 'DIM', 'HATCH', 'CUT'].every((l) => dx.layers.includes(l)), (dxfCheck.stderr || dxfCheck.stdout).slice(-200));+ check('Einzelheit B: Kanten nur im Kreis um ihre Mitte', dx?.detail === true);++ const before = ['Bracket.pdf', 'Bracket.dxf'].map((f) => fs.readFileSync(path.join(dir, 'output', 'drawings', f)));+ const png = fs.readFileSync(path.join(dir, '.soma', 'drawings', 'Bracket.png'));+ const b2 = soma(dir, 'drawing', 'build', 'drawings/skill.py');+ const after = ['Bracket.pdf', 'Bracket.dxf'].map((f) => fs.readFileSync(path.join(dir, 'output', 'drawings', f)));+ check('Gleicher Inhalt, gleiche Dateien: PDF, DXF und Bild bytegleich nach erneutem Bauen', b2.status === 0 && before.every((b, i) => b.equals(after[i]))+ && png.equals(fs.readFileSync(path.join(dir, '.soma', 'drawings', 'Bracket.png'))), b2.stdout.slice(0, 160));+ check('Ausgabe für den Agenten: Dateien und Hinweis auf das Bild', b2.stdout.includes('Drawing ok: "Bracket"') && b2.stdout.includes('output/drawings/Bracket.pdf')+ && b2.stdout.includes('.soma/drawings/Bracket.png (3307 x 2339 px)'), b2.stdout.slice(0, 300));+ const info = soma(dir, 'drawing', 'info', 'Bracket');+ check('soma drawing info: Ansichten mit Platz auf dem Blatt, Kreise, Maße mit Zeile', info.status === 0 && info.stdout.includes('Views:')+ && info.stdout.includes('circles: Ø10 x1 at (0, 0, 12); Ø8 x4') && /line \d+: 120 \(linear, top\)/.test(info.stdout), info.stdout.slice(0, 300));+ const list = soma(dir, 'drawing', 'list');+ check('soma drawing list: beide Blätter, der Fehler mit Zeile', list.stdout.includes('"Bracket"') && list.stdout.includes('"Checks"')+ && list.stdout.includes('ERROR drawings/broken.py:3'), list.stdout.slice(0, 300));++ fs.rmSync(path.join(dir, 'drawings', 'checks.py'));+ const b3 = soma(dir, 'drawing', 'build');+ check('Gelöschtes Blatt: PDF und DXF bleiben, die Ausgabe nennt sie, das Bild geht', b3.stdout.includes('Note: output/drawings/Checks.pdf belongs to no sheet anymore')+ && fs.existsSync(path.join(dir, 'output', 'drawings', 'Checks.pdf')) && !fs.existsSync(path.join(dir, '.soma', 'drawings', 'Checks.png')), b3.stdout.slice(-300));+ fs.appendFileSync(path.join(dir, 'model.py'), 'raise ValueError("kaputt")\n');+ const b4 = soma(dir, 'drawing', 'build');+ check('Modell baut nicht: Meldung mit Ort, keine Zeichnung', b4.status === 1 && b4.stderr.includes('The model does not build, so no drawing does either')+ && b4.stderr.includes('model.py:10'), b4.stderr.slice(-200));++ // 2) In der App: PDF im Code-Panel, nichts davon zählt als ungespeicherte Änderung+ app = await startApp({ name: 'drawing' });+ const { ev, waitFor } = app;+ await waitFor('Projekt und Build', () => !!window.__t && !!window.__t.project() && window.__t.status().state === 'ok');+ const proj = await ev(() => window.__t.project());+ fs.writeFileSync(path.join(proj.dir, 'model.py'), MODEL);+ fs.mkdirSync(path.join(proj.dir, 'drawings'), { recursive: true });+ fs.writeFileSync(path.join(proj.dir, 'drawings', 'bracket.py'), block + '\n');+ await waitFor('Modell gebaut', () => window.__t.status().state === 'ok' && window.__t.partCount() === 2, 90000).catch(() => {});+ await waitFor('Speicherstand', () => !!window.__t.saveState(), 10000).catch(() => {});+ const dirty0 = (await ev(() => window.__t.saveState())).dirtyFiles;+ const ab = soma(proj.dir, 'drawing', 'build');+ check('Im Projekt der App gebaut', ab.status === 0 && fs.existsSync(path.join(proj.dir, 'output', 'drawings', 'Bracket.pdf')), (ab.stderr || ab.stdout).slice(-200));+ await ev(() => window.__t.openCode('output/drawings/Bracket.pdf'));+ await waitFor('PDF gezeichnet', () => (window.__t.editor.state().pdf?.rendered ?? []).includes(1), 20000).catch(() => {});+ const pdf = (await ev(() => window.__t.editor.state())).pdf;+ const dark = await ev(() => {+ const c = document.querySelector('.pdf-page[data-page="1"] canvas');+ if (!c) return 0;+ const d = c.getContext('2d').getImageData(0, 0, c.width, c.height).data;+ let n = 0;+ for (let i = 0; i < d.length; i += 4) if (d[i] < 100) n++;+ return n;+ });+ check('PDF öffnet im Code-Panel: eine Seite im Querformat, mit Linien gezeichnet', pdf?.pages === 1 && dark > 1000, `${JSON.stringify(pdf)?.slice(0, 100)} dark=${dark}`);+ await sleep(1500); // Dateibeobachtung und Speicherstand nachziehen lassen+ const dirty1 = (await ev(() => window.__t.saveState())).dirtyFiles;+ check('PDF, DXF und Bild zählen nicht als ungespeicherte Änderung', dirty1 === dirty0, `${dirty0} -> ${dirty1}`);+ if (process.env.SMOKE_SHOTS) {+ fs.mkdirSync(path.join(APP, 'test', 'shots'), { recursive: true });+ await sleep(600);+ await app.screenshot(path.join(APP, 'test', 'shots', '19-zeichnung.png')).catch((e) => console.log('Screenshot:', e.message));+ }+ const relevant = app.page.errors.filter((e) => !/favicon/i.test(e));+ check('Keine Konsolenfehler im Renderer', relevant.length === 0, relevant.slice(0, 2).join(' | ').slice(0, 100));+} catch (e) {+ console.log('ABBRUCH:', e.message);+ t.fail();+}+if (app) { await app.stop(); cleanup(app.ud); }+if (dir) cleanup(dir);+console.log(t.fails ? `\n${t.fails} Prüfung(en) fehlgeschlagen` : '\nALLE PRÜFUNGEN BESTANDEN');+process.exit(t.fails ? 1 : 0);diff --git a/app/test/run-all.mjs b/app/test/run-all.mjsindex f51d07b..2321c13 100644--- a/app/test/run-all.mjs+++ b/app/test/run-all.mjs@@ -9,7 +9,7 @@ import path from 'node:path';const DIR = import.meta.dirname;// Längste zuerst, damit sie nicht am Ende allein laufen-const ALL = ['animation', 'fem', 'versions', 'smoke', 'editor', 'skills', 'params', 'explode', 'fasteners', 'section', 'measure', 'groups', 'packages', 'unit'];+const ALL = ['animation', 'fem', 'versions', 'smoke', 'editor', 'skills', 'params', 'explode', 'fasteners', 'drawing', 'section', 'measure', 'groups', 'packages', 'unit'];const wanted = process.argv.slice(2);const unknown = wanted.filter((s) => !ALL.includes(s));if (unknown.length) { console.log(`Unbekannte Suite: ${unknown.join(', ')}. Vorhanden: ${ALL.join(', ')}`); process.exit(2); }