Plan & Drawing Generator
Relevant source files
The following files were used as context for generating this wiki page:
The Plan & Drawing Generator creates vector-based construction plans in SVG format. It primarily visualizes architectural layouts, such as ground plans for construction projects (e.g., KiTa Rohbau), by rendering geometric primitives, text labels, and standardized engineering dimensions. The system integrates with the project's AVA (Ausschreibung, Vergabe, Abrechnung) workflow to provide visual context for bills of quantities and performance descriptions.
Architecture and Core Logic
The generator follows a functional approach where a central rendering function transforms structured plan data into an XML-compliant SVG string. The system utilizes a scaling factor of 2 pixels per millimeter (PX_PER_MM) to translate physical dimensions into screen coordinates.
Rendering Pipeline
The rendering process starts with the renderPlanSvg function, which orchestrates the creation of the background grid, plan elements, and the standardized title block.
This diagram illustrates the transformation of structured Plan data into a final SVG string through specialized rendering helpers.
Sources: lib/plan/svg.ts:147-179, lib/plan/svg.ts:16-17
Data Structures
The system relies on a hierarchical data model defined in the Plan and PlanElement types.
- Plan: Contains metadata (ID, Title, Scale) and global canvas properties (Width, Height).
- PlanElement: Defines individual drawing components like rectangles for rooms or lines for walls.
The class diagram represents the relationship between a top-level Plan and its constituent elements.
Sources: lib/plan/svg.ts:11, lib/plan/svg.ts:184-192
SVG Element Rendering
The generator supports four specific element types, each handled by a dedicated internal function to ensure proper SVG attribute mapping and XML escaping.
Supported Element Types
| Element Type | Helper Function | Purpose | Key Attributes |
|---|---|---|---|
rect | renderRect | Visualizes rooms, buildings, or zones. | x, y, width, height, fill, stroke |
line | renderLine | Draws walls or structural boundaries. | x1, y1, x2, y2, stroke-width |
text | renderText | Annotates areas with names or sizes (e.g., "17.50 m²"). | font-family, font-size, rotation |
dimension | renderDimension | Adds technical measurements with arrows and labels. | direction (horizontal/vertical), value |
Sources: lib/plan/svg.ts:25-117
Dimensioning Logic
The renderDimension function calculates offsets and draws complex groups containing a dimension line, tick marks (Abstriche), arrows, and centered labels. It supports horizontal and vertical orientations, applying a -90 degree rotation for vertical text to maintain architectural standards.
Sources: lib/plan/svg.ts:60-106
UI Implementation
The user interface for viewing plans is implemented as a specialized view within the project route.
Components
- PlanPage: An asynchronous server component that provides the layout, header, and navigation back to the main LV view.
- PlanView: A client component that renders the generated SVG. It uses
dangerouslySetInnerHTMLto inject the SVG string, as the content is generated internally by the trustedrenderPlanSvgfunction.
The sequence diagram shows the data flow from the server request to the final SVG injection in the client browser.
Sources: app/(chat)/lv/[projectId]/plan/page.tsx:10-33, app/(chat)/lv/[projectId]/plan/plan-view.tsx:5-18
Specifications and Standards
The generator adheres to specific formatting standards to ensure consistency across the AVA platform:
- Canvas Size: Defaults to DIN A2 landscape (594mm × 420mm), which results in a viewBox of
0 0 1188 840at 2 PX_PER_MM. - Grid System: A visual guide is rendered with lines every 100 pixels (representing a 50mm interval at scale).
- Title Block: A white rectangle is anchored at the bottom-right corner (
x="${w - 280}",y="${h - 50}") containing the plan title and the scale (e.g., "Maßstab: 1:100"). - Safety: An
esc()helper function sanitizes string inputs to prevent XML injection by escaping characters like&,<, and>.
Sources: lib/plan/svg.ts:16-23, lib/plan/svg.ts:174-178, lib/plan/svg.test.ts:46-49
Summary
The Plan & Drawing Generator provides a robust, code-driven way to create architectural drawings. By separating the geometric data from the rendering logic, the system allows for the dynamic generation of plans based on project metadata. It currently supports standard DIN A2 outputs with automatic dimensioning and grid alignment, serving as a visual extension of the core AVA capabilities.