Files
DOSSIER/src/ui/ExportSaveDialog.tsx
T
Claude 5a0efdae32 [259] IFC-Export für Fachplaner: lokale Geometrie mit IfcMapConversion, Bögen richtig, Mengen = Geometrie, Kontext-Option
Alle drei Beispielprojekte (Musterhaus, komplex, Wettbewerb) mit ifcopenshell 0.9 geprüft: validate-ifc.py 0 Befunde und
die neue inhaltliche Prüfung scripts/check-ifc-fachplaner.py (Struktur Project → Site → Building → Storey, jedes Bauteil
genau einmal eingeordnet, Öffnungen gefüllt und im Geschoss des Wirts, Räume mit Name/Nummer, Pset_SpaceCommon,
Qto_SpaceBaseQuantities, SIA-416-Kategorie, Wandschichten, Mengen ±1 % gegen die Geometrie, Georeferenz) als
vitest src/export/exportIfc.fachplaner.test.ts.

Behoben:
- Georeferenz: Geometrie lag in LV95-Millionen (Revit/Archicad warnen); jetzt lokal, IfcMapConversion mit dem LV95-Versatz
  des Ursprungs und OrthogonalHeight = ±0.00 m ü. M. (referenceElevationMasl, sonst Höhe des Bezugspunkts), gleich
  IfcSite.RefElevation; IFC2x3 ePSet_MapConversion ebenso. Flache Kodierung Version 5.
- Bögen in Decken- und Raumumrissen lagen an der Sehne gespiegelt (Modell: positiv = Scheitel links, Schreiber: DXF-Sinn)
  und wurden mit nur kartesischer Trimmung von ifcopenshell als Sehne gelesen: Vorzeichen gedreht, Trimmung Punkt + Winkel,
  massgebend PARAMETER. Erker komplex: Raum 51.5 → 57.4 m² (= Flächenbilanz), Bodenplatte/Decken-Volumen = Menge.
- Geschoss-GF war gleich NGF (KGF 0): Mengen jetzt aus der Flächentabelle (GF = NGF + Konstruktionsfläche), dazu
  GrossHeight/GrossVolume; Summen am Gebäude (Qto_BuildingBaseQuantities, CH_Qto_SIA416).
- Wandmengen: Bogenwände (volle Höhe über alle Schichten, 5–23 % zu viel) aus den geschriebenen Profilen bzw. dem dichten
  Netz; Formöffnungen ziehen den Umriss statt des Rechtecks ab.
- Netz-Wände mit mehreren Bändern oder Formöffnungs-Füllkörpern als ein Körper (Manifold); Füllkörper waren verdreht
  gewickelt; Netze verschweisst (komplex 2.3 → 1.6 MB).

Neu: Option „Kontext mitgeben" (Export-Dialog, CLI --kontext, Vorgabe aus): Gelände → IfcGeographicElement TERRAIN, Netze
auf Umgebungsklassen → IfcBuildingElementProxy „Kontext", am IfcSite. Entscheid: 2D-Objektbibliothek ([253]) wird nicht
exportiert (kein falscher Körper, kein geometrieloses IfcFurniture), Test: Datei mit/ohne Objekte zeichengleich.

Grösse/Zeit (Linux-Container unter Last): komplex 1.6 MB / 2.5 s, Wettbewerb 0.9 MB / 0.5 s, sampleProjectBig 19.8 MB / 5.8 s.

Offen: nicht in Archicad/Revit/Solibri/BIMcollab geöffnet (Prüfzeile 13.14 in doc/RELEASE-1.0.md); Anbauwand OG Ost im
Beispiel komplex (Netz unter dem Pultdach mit Fenster): ifcopenshell scheitert am Abzug der Öffnung (30.4 statt 7.5 m³,
in der Prüfung als bekannt markiert).

Geprüft: cargo test core (1683+) und fileio (344), tsc, vitest src/export + src/io, Goldens, i18n/Boundary, validate und
fachplaner (ifcopenshell). Nur im Linux-Container.
2026-11-14 08:40:33 +00:00

173 lines
6.8 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// Schnellexport-Dialog (modal) für die Direkt-Formate CSV/IFC/OBJ/STL aus dem
// Topbar-Export-Menü: Format wählen + Dateiname festlegen, dann speichern.
// (PDF/DXF haben eigene Options-Dialoge.) Später bekommen „Ausschnitte" einen
// vordefinierten Namen + Speicherort; dies ist der interaktive Schnellweg.
//
// Muster wie ExportDxfDialog: abgedunkeltes Overlay, Klick auf Hintergrund + Esc
// schliessen. Rein gesteuert — meldet Format + Dateiname über `onSave` nach oben
// (App führt Erzeugung + Download aus). Bezeichner englisch, UI deutsch (t()).
import { useEffect, useState } from "react";
import { t } from "../i18n";
import { useModalFocus } from "./modalFocus";
import { Dropdown } from "./Dropdown";
import type { IfcExportOptions, IfcSchema } from "../export/exportIfc";
/** Direkt-herunterladbare Exportformate (mit Datei-Endung). */
export type ExportSaveFormat = "csv" | "ifc" | "obj" | "stl" | "glb" | "step";
/** Datei-Endung je Format. */
export const EXPORT_FORMAT_EXT: Record<ExportSaveFormat, string> = {
csv: "csv",
ifc: "ifc",
obj: "obj",
stl: "stl",
glb: "glb",
step: "stp",
};
export interface ExportSaveDialogProps {
/** Vorausgewähltes Format (aus dem angeklickten Menüeintrag). */
initialFormat: ExportSaveFormat;
/** Basis-Dateiname OHNE Endung (i. d. R. Projektname). */
baseName: string;
/** `ifc`: Klassifikations-Optionen (nur bei Format IFC gesetzt). */
onSave: (format: ExportSaveFormat, filename: string, ifc?: IfcExportOptions) => void;
onClose: () => void;
}
/** Endung sicher an den Basisnamen hängen (doppelte Endung vermeiden). */
function withExt(base: string, ext: string): string {
const trimmed = base.trim() || "modell";
const lower = trimmed.toLowerCase();
return lower.endsWith(`.${ext}`) ? trimmed : `${trimmed}.${ext}`;
}
export function ExportSaveDialog({
initialFormat,
baseName,
onSave,
onClose,
}: ExportSaveDialogProps) {
const dialogRef = useModalFocus({});
useEffect(() => {
const onKey = (e: KeyboardEvent) => {
if (e.key === "Escape") onClose();
};
window.addEventListener("keydown", onKey);
return () => window.removeEventListener("keydown", onKey);
}, [onClose]);
const [format, setFormat] = useState<ExportSaveFormat>(initialFormat);
// Der Dateiname wird OHNE Endung editiert; die Endung folgt aus dem Format.
const [name, setName] = useState(baseName);
const filename = withExt(name, EXPORT_FORMAT_EXT[format]);
// IFC-Klassifikation (Schweizer Praxis): beides aus, bis die Nutzerin es wählt.
const [ebkph, setEbkph] = useState(false);
const [layerCodes, setLayerCodes] = useState(false);
const [context, setContext] = useState(false);
// IFC-Schema: IFC4 (Standard) oder IFC2x3 für ältere Fachplaner-Programme.
const [schema, setSchema] = useState<IfcSchema>("IFC4");
const onConfirm = () => onSave(format, filename, format === "ifc" ? { schema, ebkph, layerCodes, context } : undefined);
return (
<div className="imp-overlay" onClick={onClose}>
<div
className="imp-dialog"
ref={dialogRef} role="dialog"
aria-modal="true"
aria-label={t("exportSave.title")}
onClick={(e) => e.stopPropagation()}
>
<header className="imp-head">
<span className="imp-head-title">{t("exportSave.title")}</span>
<button className="imp-close" onClick={onClose} aria-label={t("export.close")}>
×
</button>
</header>
<div className="imp-body">
<section className="imp-section">
<div className="imp-section-title">{t("exportSave.format")}</div>
<Dropdown
value={format}
onChange={(v) => setFormat(v as ExportSaveFormat)}
title={t("exportSave.format")}
options={[
{ value: "csv", label: t("exportSave.fmt.csv") },
{ value: "ifc", label: t("exportSave.fmt.ifc") },
{ value: "obj", label: t("exportSave.fmt.obj") },
{ value: "stl", label: t("exportSave.fmt.stl") },
{ value: "glb", label: t("exportSave.fmt.glb") },
{ value: "step", label: t("exportSave.fmt.step") },
]}
/>
</section>
{format === "ifc" && (
<section className="imp-section">
<div className="imp-section-title">{t("exportSave.ifc.schema")}</div>
<Dropdown
value={schema}
onChange={(v) => setSchema(v as IfcSchema)}
title={t("exportSave.ifc.schema")}
options={[
{ value: "IFC4", label: t("exportSave.ifc.schema4") },
{ value: "IFC2X3", label: t("exportSave.ifc.schema2x3") },
]}
/>
<div className="imp-note">{t("exportSave.ifc.schemaHint")}</div>
<label className="imp-check">
<input type="checkbox" checked={ebkph} onChange={(e) => setEbkph(e.target.checked)} />
<span>{t("exportSave.ifc.ebkph")}</span>
</label>
<div className="imp-note">{t("exportSave.ifc.ebkphHint")}</div>
<label className="imp-check">
<input type="checkbox" checked={layerCodes} onChange={(e) => setLayerCodes(e.target.checked)} />
<span>{t("exportSave.ifc.layers")}</span>
</label>
<div className="imp-note">{t("exportSave.ifc.layersHint")}</div>
<label className="imp-check">
<input type="checkbox" checked={context} onChange={(e) => setContext(e.target.checked)} />
<span>{t("exportSave.ifc.context")}</span>
</label>
<div className="imp-note">{t("exportSave.ifc.contextHint")}</div>
<div className="imp-note">{t("exportSave.ifc.zonesNote")}</div>
</section>
)}
<section className="imp-section">
<div className="imp-section-title">{t("exportSave.filename")}</div>
<input
className="settings-num-input"
type="text"
aria-label={t("exportSave.filename")}
value={name}
data-autofocus
spellCheck={false}
onChange={(e) => setName(e.target.value)}
onKeyDown={(e) => {
if (e.key === "Enter") onConfirm();
}}
placeholder="modell"
/>
<div className="imp-note">
{filename} · {t("exportSave.locationNote")}
</div>
</section>
</div>
<footer className="imp-foot">
<button className="imp-btn" onClick={onClose}>
{t("export.cancel")}
</button>
<button className="imp-btn primary" onClick={onConfirm}>
{t("export.confirm")}
</button>
</footer>
</div>
</div>
);
}