STEP: Export (Datei → Exportieren → STEP) und Import (Datei → STEP importieren) im nativen Menue
This commit is contained in:
1 parent
b87451c3e5
commit
80d45ffdd6
8 files changed
+91
-1
No files matched your search
+26
@@ -51,6 +51,7 @@ import { LockConflictDialog } from "./ui/LockConflictDialog";
|
||||
import { UnsavedChangesDialog } from "./ui/UnsavedChangesDialog";
|
||||
import { Toast } from "./ui/Toast";
|
||||
import { isTauriRuntime, PROJECT_TEMPLATE_EXT } from "./io/projectFile";
|
||||
import { stepTextToImportedMeshes } from "./io/stepImport";
|
||||
import { checkForUpdate } from "./update/checkForUpdate";
|
||||
import type { PlanViewHandle } from "./plan/PlanView";
|
||||
import type { DisplayResolver } from "./viewport/Viewport3D";
|
||||
@@ -539,6 +540,8 @@ export default function App() {
|
||||
// Der Klick auf „DXF importieren" triggert .click() dieses Inputs; onChange
|
||||
// liest die Datei als Text und reicht sie durch parseDxf → addContextObjects.
|
||||
const dxfInputRef = useRef<HTMLInputElement>(null);
|
||||
// Verstecktes Datei-Input für den STEP-Import (Menü Datei, STEP importieren).
|
||||
const stepInputRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// Verstecktes Datei-Input für „Bild einfügen" (Werkzeug „image", s. tools.ts-
|
||||
// Kommentar) — akzeptiert auch PDF (jede Seite wird gerastert, s. pdfImport.ts);
|
||||
@@ -1824,6 +1827,7 @@ export default function App() {
|
||||
onExportIfc,
|
||||
onExportObj,
|
||||
onExportStl,
|
||||
onExportStep,
|
||||
onOpenProject,
|
||||
openProjectAtPath,
|
||||
onProjectFileChosen,
|
||||
@@ -2377,6 +2381,8 @@ export default function App() {
|
||||
onExportIfc,
|
||||
onExportObj,
|
||||
onExportStl,
|
||||
onExportStep,
|
||||
onImportStep: () => stepInputRef.current?.click(),
|
||||
onUndo: undo,
|
||||
onRedo: redo,
|
||||
onDeleteSelection: deleteSelection,
|
||||
@@ -3209,6 +3215,25 @@ export default function App() {
|
||||
e.target.value = "";
|
||||
}}
|
||||
/>
|
||||
{/* Verstecktes STEP-Datei-Input (Menü Datei, STEP importieren). */}
|
||||
<input
|
||||
ref={stepInputRef}
|
||||
type="file"
|
||||
accept=".stp,.step,.p21"
|
||||
style={{ display: "none" }}
|
||||
onChange={(e) => {
|
||||
const f = e.target.files?.[0];
|
||||
e.target.value = "";
|
||||
if (!f) return;
|
||||
void f
|
||||
.text()
|
||||
.then((text) => stepTextToImportedMeshes(text, f.name))
|
||||
.then((objs) => addContextObjectsAndFit(objs))
|
||||
.catch((err) =>
|
||||
window.alert(`${t("step.import.failed")}: ${err instanceof Error ? err.message : String(err)}`),
|
||||
);
|
||||
}}
|
||||
/>
|
||||
{/* Verstecktes Bild/PDF-Datei-Input (Werkzeug „image"). */}
|
||||
<input
|
||||
ref={imageInputRef}
|
||||
@@ -3257,6 +3282,7 @@ export default function App() {
|
||||
onExportIfc={onExportIfc}
|
||||
onExportObj={onExportObj}
|
||||
onExportStl={onExportStl}
|
||||
onExportStep={onExportStep}
|
||||
viewType={viewType}
|
||||
fov={fov}
|
||||
onFov={setFov}
|
||||
|
||||
@@ -1709,6 +1709,12 @@ export const de = {
|
||||
"exportSave.fmt.ifc": "IFC (BIM)",
|
||||
"exportSave.fmt.obj": "OBJ (3D-Mesh)",
|
||||
"exportSave.fmt.stl": "STL (3D-Mesh)",
|
||||
"exportSave.fmt.step": "STEP (B-Rep, truck)",
|
||||
"step.export.failed": "STEP-Export fehlgeschlagen",
|
||||
"step.export.skipped": "{n} Körper konnten nicht exportiert werden",
|
||||
"step.import.failed": "STEP-Import fehlgeschlagen",
|
||||
"step.import.done": "STEP importiert: {n} Körper",
|
||||
"menu.native.importStep": "STEP importieren …",
|
||||
"about.title": "Über dossier",
|
||||
"about.version": "Version",
|
||||
"about.desc": "Open Source Computer Aided Architecture Design — 2D-Vektordesign sowie normgerechte Pläne aus einem semantischen Gebäudemodell.",
|
||||
|
||||
@@ -1670,6 +1670,12 @@ export const en: Record<TranslationKey, string> = {
|
||||
"file.exportIfc": "Export IFC",
|
||||
"file.exportObj": "Export OBJ (3D mesh)",
|
||||
"file.exportStl": "Export STL (3D mesh)",
|
||||
"exportSave.fmt.step": "STEP (B-rep, truck)",
|
||||
"step.export.failed": "STEP export failed",
|
||||
"step.export.skipped": "{n} solids could not be exported",
|
||||
"step.import.failed": "STEP import failed",
|
||||
"step.import.done": "STEP imported: {n} solids",
|
||||
"menu.native.importStep": "Import STEP …",
|
||||
"file.export": "Export",
|
||||
"file.openFailed": "Could not read the project file.",
|
||||
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
// STEP-Import (ISO 10303-42 B-Rep) über truck-stepio: jede Shell der Datei wird zu einem
|
||||
// tessellierten `ImportedMesh` des Kontexts (Kategorie „Import"), anwählbar wie jeder
|
||||
// andere importierte Körper. Koordinaten bleiben unverändert (Meter, Z = Höhe).
|
||||
|
||||
import { importStepMeshes } from "../engine/truckSolid";
|
||||
import { GENERIC_IMPORT_CATEGORY } from "../model/contextCategories";
|
||||
import type { ImportedMesh } from "../model/types";
|
||||
|
||||
let counter = 0;
|
||||
|
||||
/** Liest STEP-Text → ein `ImportedMesh` je Körper. Wirft bei unlesbarer Datei. */
|
||||
export async function stepTextToImportedMeshes(text: string, fileName: string): Promise<ImportedMesh[]> {
|
||||
const base = fileName.replace(/\.[^.]+$/, "") || "STEP";
|
||||
const meshes = await importStepMeshes(text);
|
||||
const stamp = Date.now().toString(36);
|
||||
return meshes.map((m, i) => ({
|
||||
id: `imported-step-${stamp}-${counter++}`,
|
||||
type: "importedMesh" as const,
|
||||
name: meshes.length > 1 ? `${base} (${i + 1}/${meshes.length})` : base,
|
||||
categoryCode: GENERIC_IMPORT_CATEGORY.code,
|
||||
positions: m.positions,
|
||||
indices: m.indices,
|
||||
}));
|
||||
}
|
||||
@@ -32,6 +32,8 @@ export interface NativeAppMenuHandlers {
|
||||
onExportIfc: () => void;
|
||||
onExportObj: () => void;
|
||||
onExportStl: () => void;
|
||||
onExportStep: () => void;
|
||||
onImportStep: () => void;
|
||||
|
||||
onUndo: () => void;
|
||||
onRedo: () => void;
|
||||
@@ -166,6 +168,10 @@ export function useNativeAppMenu(
|
||||
text: t("menu.native.import"),
|
||||
action: () => handlersRef.current.onImport(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: t("menu.native.importStep"),
|
||||
action: () => handlersRef.current.onImportStep(),
|
||||
}),
|
||||
await Submenu.new({
|
||||
text: t("menu.native.export"),
|
||||
items: [
|
||||
@@ -193,6 +199,10 @@ export function useNativeAppMenu(
|
||||
text: "STL",
|
||||
action: () => handlersRef.current.onExportStl(),
|
||||
}),
|
||||
await MenuItem.new({
|
||||
text: "STEP",
|
||||
action: () => handlersRef.current.onExportStep(),
|
||||
}),
|
||||
],
|
||||
}),
|
||||
],
|
||||
|
||||
@@ -17,6 +17,7 @@ import { distinctImportLayers, planImportCategories } from "../io/dxfToDrawings"
|
||||
import type { ImportDecision } from "../ui/ImportDialog";
|
||||
import { exportScheduleCsv } from "../export/exportSchedule";
|
||||
import { exportIfcSpf } from "../export/exportIfc";
|
||||
import { exportProjectStep } from "../export/exportStep";
|
||||
import { exportObj, exportStl } from "../export/exportMesh";
|
||||
import type { ExportSaveFormat } from "../ui/ExportSaveDialog";
|
||||
import { saveTextFile } from "../io/saveFile";
|
||||
@@ -442,6 +443,18 @@ export function useProjectFileActions(
|
||||
case "stl":
|
||||
downloadTextFile(exportStl(project), filename);
|
||||
break;
|
||||
case "step":
|
||||
// B-Rep via truck-WASM (asynchron): Körper, die truck nicht bauen kann, werden
|
||||
// übersprungen — der Export bleibt trotzdem erhalten, Hinweis per Meldung.
|
||||
void exportProjectStep(project, filename.replace(/\.[^.]+$/, ""))
|
||||
.then((r) => {
|
||||
downloadTextFile(r.text, filename);
|
||||
if (r.skipped.length > 0) {
|
||||
window.alert(t("step.export.skipped", { n: r.skipped.length }));
|
||||
}
|
||||
})
|
||||
.catch((e) => window.alert(`${t("step.export.failed")}: ${e instanceof Error ? e.message : String(e)}`));
|
||||
break;
|
||||
}
|
||||
};
|
||||
// Schnellexport aus dem Topbar-Menü öffnet den Format-/Dateiname-Dialog
|
||||
@@ -450,6 +463,7 @@ export function useProjectFileActions(
|
||||
const onExportIfc = () => setExportSaveFormat("ifc");
|
||||
const onExportObj = () => setExportSaveFormat("obj");
|
||||
const onExportStl = () => setExportSaveFormat("stl");
|
||||
const onExportStep = () => setExportSaveFormat("step");
|
||||
// Unter Tauri: nativer Öffnen-Dialog (echter Pfad → Lock möglich). Im
|
||||
// Browser: verstecktes <input type=file> wie bisher (kein echter Pfad, also
|
||||
// ohne Lock — File-API im Browser liefert keinen Dateisystempfad).
|
||||
@@ -570,6 +584,7 @@ export function useProjectFileActions(
|
||||
onExportIfc,
|
||||
onExportObj,
|
||||
onExportStl,
|
||||
onExportStep,
|
||||
onOpenProject,
|
||||
onProjectFileChosen,
|
||||
runImport,
|
||||
|
||||
@@ -12,7 +12,7 @@ import { t } from "../i18n";
|
||||
import { Dropdown } from "./Dropdown";
|
||||
|
||||
/** Direkt-herunterladbare Exportformate (mit Datei-Endung). */
|
||||
export type ExportSaveFormat = "csv" | "ifc" | "obj" | "stl";
|
||||
export type ExportSaveFormat = "csv" | "ifc" | "obj" | "stl" | "step";
|
||||
|
||||
/** Datei-Endung je Format. */
|
||||
export const EXPORT_FORMAT_EXT: Record<ExportSaveFormat, string> = {
|
||||
@@ -20,6 +20,7 @@ export const EXPORT_FORMAT_EXT: Record<ExportSaveFormat, string> = {
|
||||
ifc: "ifc",
|
||||
obj: "obj",
|
||||
stl: "stl",
|
||||
step: "stp",
|
||||
};
|
||||
|
||||
export interface ExportSaveDialogProps {
|
||||
@@ -87,6 +88,7 @@ export function ExportSaveDialog({
|
||||
{ value: "ifc", label: t("exportSave.fmt.ifc") },
|
||||
{ value: "obj", label: t("exportSave.fmt.obj") },
|
||||
{ value: "stl", label: t("exportSave.fmt.stl") },
|
||||
{ value: "step", label: t("exportSave.fmt.step") },
|
||||
]}
|
||||
/>
|
||||
</section>
|
||||
|
||||
@@ -122,6 +122,7 @@ export interface TopBarProps {
|
||||
onExportIfc: () => void;
|
||||
onExportObj: () => void;
|
||||
onExportStl: () => void;
|
||||
onExportStep?: () => void;
|
||||
|
||||
// Kamera-Settings (FOV), ZUSÄTZLICH zur bestehenden im „Ansichten"-Ribbon-
|
||||
// Tab (ViewRibbonTab) und im 3D-Ribbon-Tab (Ribbon3dTab) — hier direkt neben
|
||||
|
||||
Reference in new issue
Block a user