Merge branch 'worktree-agent-ac143182c4c59003b' into claude/practical-noether-1hb2s1

This commit is contained in:
Claude committed 2026-11-12 09:21:02 +00:00
commit 9870098dcc
33 files changed
+798 -157

No files matched your search

+17 -4
View File
@@ -22,7 +22,7 @@
// --hide <Code|Name,…> blendet Klassen aus (z. B. --hide "Schatten,Auto-Bemassung") [180]
// dossier-cli <projekt.obp> ifc [--ebkph] [--ebenen] (IFC mit eBKP-H-Hauptgruppen bzw. Modell-Ebenen als Klassifikation)
// --schema 4|2x3: IFC4 (Standard) oder IFC2x3 (Coordination View 2.0)
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
// dossier-cli <projekt.obp> dxf [--binary] [--scale 100] [--dim-unit cm] [--layout]|dwg|ifc|step|obj [--no-mtl]|stl|glb|gltf|schedule [--openings|--elements|--rooms] [--format json|csv|svg|pdf]|kennzahlen [--sia416] [--ivhb] [--format json|csv|svg|pdf] [--agsf m2] [--gruenflaeche m2] [--agf-basis gf|ngf|nf] [--untergeschosse]|raumprogramm [--import tabelle] [--sheet name|nr] [--mode replace|append] [--tolerance %] [--generate] [--format json|csv|svg|pdf] [--save projekt.obp]|sun [--level EG] [--out datei]
// glb/gltf = glTF 2.0 (Y-up, Meter, Geschoss als Eltern; --flat ohne Geschoss-Knoten)
// dossier-cli convert <eingabe> <ausgabe> [--cmd "befehl"]… Format nach Endung: dxf/dwg/ifc/obp → obp-Import,
// obp → dxf/dwg/ifc/obj/stl/glb/gltf/step; --cmd: weitere Befehle
@@ -52,7 +52,7 @@
// WASM-Pakete (src/engine/pkg*) werden aus DOSSIER_WASM_DIR bzw. `<repo>/src/engine` gelesen.
import { readFileSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
import { basename, dirname, join, resolve } from "node:path";
import { fileURLToPath } from "node:url";
import {
buildPlanDxf,
@@ -72,6 +72,7 @@ import {
computeSection,
exportIfcSpf,
exportObj,
exportMtl,
exportProjectStep,
exportScheduleCsv,
computeKennzahlen,
@@ -443,7 +444,7 @@ export async function run(argv: string[]): Promise<number> {
if (file === "mcp" && args.flags.has("app")) return runAppBridge(args);
if (!file || (!command && args.cmds.length === 0)) {
process.stderr.write(
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|dwg|ifc|import-ifc|import-mesh|erkennen|step|obj|stl|glb|gltf|schedule|kennzahlen|raumprogramm|sun|model3d> [Optionen]\n" +
"Aufruf: dossier-cli <projekt.obp> <info|validate|migrate|plan|section|elevation|dxf|dwg|ifc|import-ifc|import-mesh|erkennen|step|obj [--no-mtl]|stl|glb|gltf|schedule|kennzahlen|raumprogramm|sun|model3d> [Optionen]\n" +
" dossier-cli convert <eingabe.dxf|dwg|ifc|pdf|obj|stl|gltf|glb|ply|obp> <ausgabe.obp|dxf|dwg|ifc|obj|stl|glb|gltf|step> [--cmd \"befehl …\"]…\n" +
" dossier-cli <projekt.obp> --cmd \"befehl …\" [--cmd …] ({last} = zuletzt geschriebene Datei)\n" +
" dossier-cli pointcloud-info <datei> [--voxel 0.05] [--max 2000000]\n" +
@@ -798,7 +799,19 @@ async function execute(project: Project, file: string, command: string, rest: st
return 0;
case "obj":
await loadFileio();
out(args, exportObj(project), `${project.name || "projekt"}.obj`);
// [201] Mit MTL (Farben) daneben: `--out haus.obj` schreibt auch `haus.mtl`; `--out -` oder `--no-mtl`: nur das OBJ
// (Farben dann als Kommentar im Kopf).
{
const target = args.flags.get("out") ?? `${project.name || "projekt"}.obj`;
if (target === "-" || args.flags.has("no-mtl")) {
out(args, exportObj(project), `${project.name || "projekt"}.obj`);
} else {
const mtlPath = target.replace(/\.obj$/i, "") + ".mtl";
out(args, exportObj(project, {}, basename(mtlPath)), target);
writeFileSync(mtlPath, exportMtl(project));
process.stderr.write(`geschrieben: ${mtlPath}\n`);
}
}
return 0;
case "stl":
await loadFileio();
+1 -1
View File
@@ -13,7 +13,7 @@ export { projectGeoOrigin } from "../model/geoRebase";
export { ensureContextCategories } from "../model/contextCategories";
export { projectToWorldCoords } from "../model/geoRebase";
export { exportScheduleCsv } from "../export/exportSchedule";
export { exportObj, exportStl, exportGlb, exportGltf } from "../export/exportMesh";
export { exportObj, exportMtl, exportStl, exportGlb, exportGltf } from "../export/exportMesh";
export { exportProjectStep } from "../export/exportStep";
export { planToSvgString } from "../export/planToSvgString";
export { setWasmBytesProvider } from "../engine/wasmSource";
+37 -1
View File
@@ -3,7 +3,7 @@
import { describe, it, expect } from "vitest";
import "../engine/fileioWasm.setup";
import validator from "gltf-validator";
import { exportGlb, exportGltf, exportObj } from "./exportMesh";
import { exportGlb, exportGltf, exportMtl, exportObj } from "./exportMesh";
import { sampleProject } from "../model/sampleProject";
interface Gltf {
@@ -83,3 +83,39 @@ describe("glTF-Export", () => {
expect(g.materials.some((m) => names.includes(m.name))).toBe(true);
});
});
describe("[201] Normalen und MTL", () => {
it("jede Primitive trägt NORMAL (gleiche Anzahl wie POSITION); Validator ohne Meldung zu Normalen", async () => {
const glb = exportGlb(sampleProject);
const g = glbJson(glb) as Gltf & { meshes: { primitives: { attributes: { POSITION: number; NORMAL?: number } }[] }[] };
for (const m of g.meshes) {
for (const p of m.primitives) {
expect(p.attributes.NORMAL).toBeDefined();
expect(g.accessors[p.attributes.NORMAL!].count).toBe(g.accessors[p.attributes.POSITION].count);
expect(g.accessors[p.attributes.NORMAL!].type).toBe("VEC3");
}
}
const report = await validator.validateBytes(glb, { maxIssues: 200 });
const normalIssues = report.issues.messages.filter((m) => /NORMAL|normal/.test(m.code + m.message));
expect(normalIssues).toEqual([]);
});
it("OBJ: vn zu jeder Fläche, usemtl je Material, mtllib nur mit MTL; MTL nennt jedes verwendete Material", () => {
const withMtl = exportObj(sampleProject, {}, "haus.mtl");
const lines = withMtl.split("\n");
expect(lines).toContain("mtllib haus.mtl");
const faces = lines.filter((l) => l.startsWith("f "));
expect(lines.filter((l) => l.startsWith("vn ")).length).toBeGreaterThan(0);
for (const f of faces) expect(f).toMatch(/^f \d+\/\/\d+ \d+\/\/\d+ \d+\/\/\d+$/);
const used = new Set(lines.filter((l) => l.startsWith("usemtl ")).map((l) => l.slice(7)));
expect(used.size).toBeGreaterThan(1);
const mtl = exportMtl(sampleProject);
const defined = new Set(mtl.split("\n").filter((l) => l.startsWith("newmtl ")).map((l) => l.slice(7)));
for (const u of used) expect(defined.has(u), u).toBe(true);
expect(mtl).toMatch(/\nKd [\d.]+ [\d.]+ [\d.]+\n/);
// Ohne MTL: keine mtllib, Farben im Kopf als Kommentar.
const plain = exportObj(sampleProject);
expect(plain).not.toContain("mtllib");
expect(plain).toMatch(/\n# \S+: Kd /);
});
});
+10 -1
View File
@@ -10,7 +10,7 @@ import { join } from "node:path";
import "../engine/fileioWasm.setup";
import { exportIfcSpf, ifcGuid } from "./exportIfc";
import { wallMeshVolumes } from "./meshScene.testutil";
import { sampleProject } from "../model/sampleProject";
import { emptyProject, sampleProject } from "../model/sampleProject";
import { buildComplexSampleProject } from "../model/sampleProjectComplex";
import type { Project } from "../model/types";
@@ -164,6 +164,15 @@ describe.skipIf(!hasIfcOpenShell)("IFC-Export gegen ifcopenshell", { timeout: 60
expect(r.out).toContain("0 Befunde");
expect(r.status).toBe(0);
});
it("[201] Import → Export mit übernommenen GlobalIds: gültig (22 Zeichen, keine doppelten)", async () => {
const { importIfcInto } = await import("../io/importView.testutil");
const first = (await importIfcInto(emptyProject, new TextEncoder().encode(exportIfcSpf(sampleProject)), { elements: true })).project;
const ifc = exportIfcSpf(first);
expect(ifc).toContain(`'${first.walls[0].ifcGlobalId}'`);
const r = validate("globalid-rundreise", ifc);
expect(r.out).toContain("0 Befunde");
expect(r.status).toBe(0);
}, 240_000);
it("[191] Decken/Räume mit Bogenkanten: IfcCompositeCurve mit IfcTrimmedCurve, gültig", () => {
const ifc = exportIfcSpf(buildComplexSampleProject());
expect(ifc).toContain("IFCCOMPOSITECURVE(");
+1 -1
View File
@@ -86,7 +86,7 @@ function objVolumes(obj: string): Map<string, number> {
cur = l.slice(2).trim();
out.set(cur, 0);
} else if (l.startsWith("f ")) {
const [a, b, c] = l.slice(2).trim().split(/\s+/).map((i) => verts[Number(i) - 1]);
const [a, b, c] = l.slice(2).trim().split(/\s+/).map((i) => verts[Number(i.split("/")[0]) - 1]); // [201]: `v//vn`
const v =
a[0] * (b[1] * c[2] - b[2] * c[1]) - a[1] * (b[0] * c[2] - b[2] * c[0]) + a[2] * (b[0] * c[1] - b[1] * c[0]);
out.set(cur, (out.get(cur) ?? 0) + v / 6);
+1 -1
View File
@@ -164,7 +164,7 @@ function parseObjFaces(obj: string): number[][] {
return obj
.split("\n")
.filter((l) => l.startsWith("f "))
.map((l) => l.slice(2).trim().split(/\s+/).map(Number));
.map((l) => l.slice(2).trim().split(/\s+/).map((t) => Number(t.split("/")[0]))); // [201]: `v//vn`
}
describe("exportObj — Wavefront-OBJ-Export", () => {
+12 -4
View File
@@ -38,10 +38,17 @@ function write<T extends string | Uint8Array>(project: Project, opts: MeshOption
* Baut einen vollständigen Wavefront-OBJ-String des 3D-Gebäudemodells (Meter, Y-up rechtshändig:
* Modell (x, y, z-hoch) → (x, z, −y)). Ein `o`-Objekt je Bauteil-Vorkommen (Wand, Decke, Extrusion, Dach,
* Treppe, Stütze, Fenster/Tür, Kontext-Mesh). Leeres Projekt ⇒ gültige Datei nur mit Kopf-Kommentaren.
* Verlangt das geladene Format-Modul (`await loadFileio()`).
* Mit Normalen (`vn`, geteilt bis 30° Knickwinkel wie die 3D-Anzeige) und `usemtl` je Material ([201]). `mtlName` =
* Dateiname der MTL daneben (`mtllib`, Datei von {@link exportMtl}); leer ⇒ ohne MTL, die Farben stehen dann als
* Kommentar im Kopf. Verlangt das geladene Format-Modul (`await loadFileio()`).
*/
export function exportObj(project: Project, opts: MeshOptions = {}): string {
return write(project, opts, false, (m, b, s) => m.export_mesh_obj_flat(b, s));
export function exportObj(project: Project, opts: MeshOptions = {}, mtlName = ""): string {
return write(project, opts, false, (m, b, s) => m.export_mesh_obj_flat(b, s, mtlName));
}
/** MTL-Datei mit den Farben (`Kd`, Deckkraft `d`) der OBJ-Materialien aus {@link exportObj} ([201]). */
export function exportMtl(project: Project, opts: MeshOptions = {}): string {
return write(project, opts, false, (m, b, s) => m.export_mesh_mtl_flat(b, s));
}
/**
@@ -63,7 +70,8 @@ export interface GltfOptions extends MeshOptions {
* glTF 2.0 binär (GLB) für Blender, Twinmotion, Enscape, Web-Viewer. Ein Knoten je Bauteil (Name
* `Wand_<id>`, `Decke_<id>`, `Dach_<id>`, `Treppe_<id>`, `Stuetze_<id>`, `Fenster_<id>`, `Tuer_<id>`,
* `Extrusion_<id>`, `Kontext_<id>`, `Gelaende_<id>`; `extras` = Typ + id), PBR-Materialien mit der
* Farbe der Bauteilschicht, Verglasung transparent (`BLEND`), Geschosse als Eltern-Knoten. Meter;
* Farbe der Bauteilschicht, Verglasung transparent (`BLEND`), `NORMAL` je Ecke (geteilt bis 30° Knickwinkel wie die
* 3D-Anzeige, scharfe Kanten bleiben kantig), Geschosse als Eltern-Knoten. Meter;
* rechtshändig, Y-up: Modell (x, y, z-hoch) → (x, z, −y), Norden = −Z. Verlangt das geladene
* Format-Modul (`await loadFileio()`).
*/
+11
View File
@@ -121,6 +121,17 @@ describe("BCF-GlobalId-Zuordnung", () => {
expect(resolveGuids(sampleProject, [g]).selection.wallIds).toEqual([w.id]);
});
it("[201] Bauteil mit übernommener ifcGlobalId: sie gilt statt der abgeleiteten (beide Richtungen)", () => {
const own = "2O2Fr$t4X7Zf8NOew3FLOH";
const p = { ...sampleProject, walls: sampleProject.walls.map((w, i) => (i === 0 ? { ...w, ifcGlobalId: own } : w)) } as Project;
const w = p.walls[0];
expect(resolveGuids(p, [own]).selection.wallIds).toEqual([w.id]);
expect(resolveGuids(p, [ifcGuid(`${p.id}/wall/${w.id}`)]).missing).toHaveLength(1);
const sel = emptyBcfSelection();
sel.wallIds = [w.id];
expect(selectionToGuids(p, sel)).toEqual([own]);
});
it("unbekannte GUIDs werden gemeldet", () => {
const r = resolveGuids(sampleProject, ["0000000000000000000000", ifcGuid(`${sampleProject.id}/wall/${sampleProject.walls[0].id}`)]);
expect(r.missing).toEqual(["0000000000000000000000"]);
+25 -19
View File
@@ -2,7 +2,8 @@
//
// Dieselbe Ableitung wie der IFC-Export (`exportIfc.ts`/`ifc_export/mod.rs`: `ifcGuid("<Projekt-id>/<Art>/<id>")`),
// damit die Rundreise Dossier → IFC → Solibri → BCF → Dossier trifft. Importierte Meshes tragen die
// GlobalId ihres Quell-Bauteils (`ImportedMesh.ifcGlobalId`). Bauteile, die im Export nicht vorkommen
// GlobalId ihres Quell-Bauteils (`ImportedMesh.ifcGlobalId`); erkannte Bauteile des IFC-Imports ebenso (`ifcGlobalId`,
// [201]: der Export schreibt sie zurück, sie gilt statt der abgeleiteten). Bauteile, die im Export nicht vorkommen
// (2D-Zeichnungen, Gruppen), haben keine GlobalId.
import type { BcfViewpoint } from "./bcf";
@@ -49,17 +50,21 @@ interface Target {
export function buildGuidIndex(project: Project): Map<string, Target> {
const index = new Map<string, Target>();
const pid = project.id;
const add = (key: string, channel: BcfChannel, id: string) => index.set(ifcGuid(`${pid}/${key}/${id}`), { channel, id });
for (const w of project.walls ?? []) add("wall", "wallIds", w.id);
for (const c of project.ceilings ?? []) add("slab", "ceilingIds", c.id);
for (const r of project.roofs ?? []) add("roof", "roofIds", r.id);
for (const c of project.columns ?? []) add("column", "columnIds", c.id);
for (const s of project.stairs ?? []) add("stair", "stairIds", s.id);
for (const e of project.extrudedSolids ?? []) add("extrusion", "extrudedSolidIds", e.id);
for (const r of project.rooms ?? []) add("space", "roomIds", r.id);
// Übernommene GlobalId (Import) vor der abgeleiteten; bei doppelter GlobalId gilt der erste (wie im Export).
const add = (key: string, channel: BcfChannel, id: string, own?: string) => {
const g = own || ifcGuid(`${pid}/${key}/${id}`);
if (!index.has(g)) index.set(g, { channel, id });
};
for (const w of project.walls ?? []) add("wall", "wallIds", w.id, w.ifcGlobalId);
for (const c of project.ceilings ?? []) add("slab", "ceilingIds", c.id, c.ifcGlobalId);
for (const r of project.roofs ?? []) add("roof", "roofIds", r.id, r.ifcGlobalId);
for (const c of project.columns ?? []) add("column", "columnIds", c.id, c.ifcGlobalId);
for (const s of project.stairs ?? []) add("stair", "stairIds", s.id, s.ifcGlobalId);
for (const e of project.extrudedSolids ?? []) add("extrusion", "extrudedSolidIds", e.id, e.ifcGlobalId);
for (const r of project.rooms ?? []) add("space", "roomIds", r.id, r.ifcGlobalId);
for (const o of project.openings ?? []) {
// Tür/Fenster (IfcDoor/IfcWindow) und Öffnung (IfcOpeningElement) gehören zur selben Dossier-Öffnung.
add("fill", "openingIds", o.id);
add("fill", "openingIds", o.id, o.ifcGlobalId);
add("opening", "openingIds", o.id);
}
for (const o of project.context ?? []) {
@@ -96,15 +101,16 @@ export function viewpointGuids(vp: BcfViewpoint): string[] {
export function selectionToGuids(project: Project, sel: BcfSelection): string[] {
const pid = project.id;
const guids: string[] = [];
const g = (key: string, ids: string[]) => ids.forEach((id) => guids.push(ifcGuid(`${pid}/${key}/${id}`)));
g("wall", sel.wallIds);
g("slab", sel.ceilingIds);
g("roof", sel.roofIds);
g("column", sel.columnIds);
g("stair", sel.stairIds);
g("extrusion", sel.extrudedSolidIds);
g("space", sel.roomIds);
g("fill", sel.openingIds);
const g = (key: string, ids: string[], items: { id: string; ifcGlobalId?: string }[] | undefined) =>
ids.forEach((id) => guids.push(items?.find((e) => e.id === id)?.ifcGlobalId || ifcGuid(`${pid}/${key}/${id}`)));
g("wall", sel.wallIds, project.walls);
g("slab", sel.ceilingIds, project.ceilings);
g("roof", sel.roofIds, project.roofs);
g("column", sel.columnIds, project.columns);
g("stair", sel.stairIds, project.stairs);
g("extrusion", sel.extrudedSolidIds, project.extrudedSolids);
g("space", sel.roomIds, project.rooms);
g("fill", sel.openingIds, project.openings);
for (const id of sel.contextObjectIds) {
const o = (project.context ?? []).find((c) => c.id === id);
if (o?.type === "importedMesh" && o.ifcGlobalId) guids.push(o.ifcGlobalId);
+66
View File
@@ -0,0 +1,66 @@
// [201] IFC-GlobalId-Rundreise: der Import setzt `ifcGlobalId` an jedem erkannten Bauteil (Wand, Öffnung, Decke, Stütze, Dach,
// Treppe, Raum, Extrusion), der Export schreibt sie zurück; ohne sie bleibt es bei der abgeleiteten GUID. Doppelte
// GlobalIds (Datei zweimal importiert) landen nie doppelt in der Ausgabe.
import "../engine/fileioWasm.setup";
import { describe, expect, it } from "vitest";
import { exportIfcSpf } from "../export/exportIfc";
import { emptyProject, sampleProject } from "../model/sampleProject";
import type { Project } from "../model/types";
import { importIfcInto } from "./importView.testutil";
const bytesOf = (s: string) => new TextEncoder().encode(s);
/** GlobalIds je IFC-Klasse (nur die 22-stelligen Kennungen am Anfang einer Entität). */
function guidsByClass(spf: string): Map<string, string[]> {
const out = new Map<string, string[]>();
for (const m of spf.matchAll(/#\d+=(IFC[A-Z0-9]+)\('([0-9A-Za-z_$]{22})'/g)) {
out.set(m[1], [...(out.get(m[1]) ?? []), m[2]]);
}
for (const v of out.values()) v.sort();
return out;
}
async function imported(base: Project, src: Project): Promise<Project> {
return (await importIfcInto(base, bytesOf(exportIfcSpf(src)), { elements: true })).project;
}
const BIM = ["IFCWALL", "IFCSLAB", "IFCDOOR", "IFCWINDOW", "IFCROOF", "IFCSTAIR", "IFCSPACE"];
describe("[201] IFC-GlobalId-Rundreise", () => {
it("Import setzt ifcGlobalId an jedem erkannten Bauteil", async () => {
const p = await imported(emptyProject, sampleProject);
const all = [...p.walls, ...(p.openings ?? []), ...(p.ceilings ?? []), ...(p.roofs ?? []), ...(p.stairs ?? []), ...(p.rooms ?? [])];
expect(all.length).toBeGreaterThan(10);
for (const e of all) expect(e.ifcGlobalId, `${e.type} ${e.id}`).toMatch(/^[0-3][0-9A-Za-z_$]{21}$/);
});
it("Import → Export: gleiche GlobalIds je Klasse wie die Quelldatei", async () => {
const a = guidsByClass(exportIfcSpf(sampleProject));
const p = await imported(emptyProject, sampleProject);
const b = guidsByClass(exportIfcSpf(p));
for (const cls of BIM) {
expect(a.get(cls)?.length ?? 0, `${cls} in der Quelle`).toBeGreaterThan(0);
expect(b.get(cls), cls).toEqual(a.get(cls));
}
});
it("ohne ifcGlobalId bleibt die abgeleitete GUID (deterministisch wie bisher)", () => {
const x = guidsByClass(exportIfcSpf(sampleProject));
const y = guidsByClass(exportIfcSpf(sampleProject));
expect(x.get("IFCWALL")).toEqual(y.get("IFCWALL"));
});
it("dieselbe Datei zweimal importiert: keine GlobalId doppelt in der Ausgabe", async () => {
const once = await imported(emptyProject, sampleProject);
const twice = await imported(once, sampleProject);
expect(twice.walls.length).toBe(once.walls.length * 2);
const spf = exportIfcSpf(twice);
const all = [...spf.matchAll(/#\d+=IFC[A-Z0-9]+\('([0-9A-Za-z_$]{22})'/g)].map((m) => m[1]);
expect(new Set(all).size).toBe(all.length);
// Die erste Kopie behält die ursprünglichen GlobalIds.
const src = guidsByClass(exportIfcSpf(sampleProject)).get("IFCWALL")!;
const out = new Set(guidsByClass(spf).get("IFCWALL")!);
for (const g of src) expect(out.has(g)).toBe(true);
});
});
+40
View File
@@ -70,6 +70,11 @@ export type Ceiling = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "30" für Decken. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/**
* Vorsprung im Baurecht ([63]: Balkon, Erker): darf mit `SiteRules.projectionDepth`/
* `projectionShare` in den Grenzabstand ragen. Fehlt ⇒ normales Bauteil.
@@ -208,6 +213,11 @@ export type Column = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "50" für Tragwerk. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** Einfügepunkt (Profil-Mitte) im Grundriss (Meter). */
@@ -1315,6 +1325,11 @@ export type ExtrudedSolid = {
* [180] Klasse (Ebene/Kategorie) wie bei jedem Bauteil: Sichtbarkeit in Grundriss, Schnitt und Ansicht.
*/
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/**
* Geschlossenes Profil in der XY-Ebene (Grundriss), ≥3 Punkte. Bei einem
* Kreis-Profil (`circle` gesetzt) eine Tessellierung des Kreises (48-Eck) —
@@ -2331,6 +2346,11 @@ export type Opening = {
hostWallId: string;
/** Grafik-Kategorie (Ebene), z. B. "21" für Türen/Fenster. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** Bauteilnummer (Fenster-/Türliste); leer = automatisch je Geschoss nummeriert. */
@@ -3027,6 +3047,11 @@ export type Roof = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "35" für Dächer. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/**
@@ -3176,6 +3201,11 @@ export type Room = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "45" für Räume. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** SIA-416-Blatt-Kategorie (HNF/NNF/VF/FF/KGF). */
@@ -3456,6 +3486,11 @@ export type Stair = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "40" für Treppen. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/** Objekt-Sperre, analog `Wall.locked`. */
locked?: boolean;
/** Grundform (gerade / L / Wendel). */
@@ -3989,6 +4024,11 @@ export type Wall = {
floorId: string;
/** Grafik-Kategorie (Ebene), z. B. "20" für Wände. */
categoryCode: string;
/**
* [201] IFC-GlobalId des Quell-Bauteils (IFC-Import); der IFC-Export schreibt sie zurück, damit
* die Rundreise dieselben GUIDs behält. Kopien (Einfügen, Kopieren, Reihe, Wand teilen) tragen sie NICHT.
*/
ifcGlobalId?: string;
/**
* Vorsprung im Baurecht ([63]: Wand eines Erkers): darf mit `SiteRules.projectionDepth`/
* `projectionShare` in den Grenzabstand ragen. Fehlt ⇒ normales Bauteil.
+49
View File
@@ -146,3 +146,52 @@ function browserDownloadBlob(blob: Blob, defaultName: string): boolean {
}, 4000);
return true;
}
/** Hauptdatei samt Begleitdatei, die auf sie verweist ([201], OBJ + MTL). */
export interface TextWithCompanion {
main: string;
companion: string;
}
/**
* Speichert eine Textdatei und eine Begleitdatei mit gleichem Namen, aber anderer Endung (OBJ + MTL).
* `build` bekommt den Dateinamen der Begleitdatei (für den Verweis in der Hauptdatei, z. B. `mtllib`).
* - Unter Tauri: Speichern-Dialog für die Hauptdatei, danach ein zweiter für die Begleitdatei (Vorschlag: gleicher Ordner und
* Stamm) — der Dialog gibt den Pfad frei; ein stilles Schreiben neben die Hauptdatei dürfte am Dateizugriff scheitern.
* Bricht man den zweiten ab, bleibt die Hauptdatei mit totem Verweis (nur die Farben fehlen dann).
* - Im Browser: zwei Downloads nacheinander.
*
* @returns `true` wenn die Hauptdatei geschrieben wurde, `false` bei Abbruch.
*/
export async function saveTextWithCompanion(
build: (companionName: string) => TextWithCompanion,
defaultName: string,
companionExt: string,
filters?: FileDialogFilter[],
companionFilters?: FileDialogFilter[],
): Promise<boolean> {
const stemOf = (name: string) => name.replace(/^.*[\\/]/, "").replace(/\.[^.]*$/, "");
if (isTauri()) {
try {
const { save } = await import("@tauri-apps/plugin-dialog");
const { writeTextFile } = await import("@tauri-apps/plugin-fs");
const path = await save({ defaultPath: defaultName, filters });
if (!path) return false;
const companionName = `${stemOf(path)}.${companionExt}`;
const files = build(companionName);
await writeTextFile(path, files.main);
const companionPath = await save({ defaultPath: path.replace(/[^\\/]*$/, companionName), filters: companionFilters });
if (companionPath) await writeTextFile(companionPath, files.companion);
return true;
} catch (err) {
if (!warnedFallback) {
warnedFallback = true;
console.warn("Nativer Speichern-Dialog fehlgeschlagen, nutze Browser-Download.", err);
}
}
}
const companionName = `${stemOf(defaultName)}.${companionExt}`;
const files = build(companionName);
browserDownload(files.main, defaultName, "application/octet-stream");
return browserDownload(files.companion, companionName, "application/octet-stream");
}
+5 -3
View File
@@ -26,9 +26,9 @@ import { exportScheduleCsv } from "../export/exportSchedule";
import { exportIfcSpf, type IfcExportOptions } from "../export/exportIfc";
import { loadFileio } from "../engine/fileioWasm";
import { exportProjectStep } from "../export/exportStep";
import { exportGlb, exportObj, exportStl } from "../export/exportMesh";
import { exportGlb, exportMtl, exportObj, exportStl } from "../export/exportMesh";
import type { ExportSaveFormat } from "../ui/ExportSaveDialog";
import { saveBinaryFile, saveTextFile } from "../native/saveFile";
import { saveBinaryFile, saveTextFile, saveTextWithCompanion } from "../native/saveFile";
import {
saveProjectFile,
openProjectFileNative,
@@ -583,7 +583,9 @@ export function useProjectFileActions(
void loadFileio()
.then(() => {
if (format === "glb") void saveBinaryFile(exportGlb(project), filename, "model/gltf-binary");
else downloadTextFile(format === "obj" ? exportObj(project) : exportStl(project), filename);
// [201] OBJ mit MTL (Farben) als zweite Datei gleichen Namens; STL kennt keine Farben.
else if (format === "obj") void saveTextWithCompanion((mtlName) => ({ main: exportObj(project, {}, mtlName), companion: exportMtl(project) }), filename, "mtl");
else downloadTextFile(exportStl(project), filename);
})
.catch((e) => notify(`${t("mesh.export.failed")}: ${e instanceof Error ? e.message : String(e)}`, "error"));
break;