44from ezdxf.addons.drawing import Frontend, RenderContext, pymupdf, layout, config
55from ezdxf.tools.text import MTextEditor
66from ezdxf.addons import odafc
7- import tempfile
87import os
98from datetime import datetime
109import uuid
1110import zipfile
12- from upload import upload_file
1311from ezdxf import bbox, colors
1412import math
1513from typing import List, Tuple
@@ -34,16 +32,17 @@ def __init__(self, plan_name: str = "Survey Plan", scale: float = 1.0, dxf_versi
3432 self.doc.header["$ANGBASE"] = 90.0 # set 0° direction to North
3533
3634 def setup_layers(self):
37- self.doc.layers.add(name="BEACONS", color=colors.BLACK)
3835 self.doc.layers.add(name="LABELS", color=colors.BLACK)
3936 self.doc.layers.add(name="FRAME", color=colors.BLACK)
4037 self.doc.layers.add(name="TITLE_BLOCK", color=colors.BLACK)
4138 self.doc.layers.add(name="FOOTER", color=colors.BLACK)
4239
4340 def setup_cadastral_layers(self):
41+ self.doc.layers.add(name="BEACONS", color=colors.BLACK)
4442 self.doc.layers.add(name="PARCELS", color=colors.RED)
4543
4644 def setup_topographic_layers(self):
45+ self.doc.layers.add(name="BEACONS", color=colors.BLACK)
4746 self.doc.layers.add(name="BOUNDARY", color=colors.RED)
4847 self.doc.layers.add('CONTOUR_MAJOR', true_color=ezdxf.colors.rgb2int((127, 31, 0)), linetype="Continuous",
4948 lineweight=35)
@@ -58,6 +57,7 @@ def setup_topographic_layers(self):
5857 lineweight=25)
5958
6059 def setup_layout_layers(self):
60+ self.doc.layers.add(name="BEACONS", color=colors.BLACK)
6161 self.doc.layers.add(name="BOUNDARY", color=colors.RED, linetype="CONTINUOUS", lineweight=50)
6262 self.doc.layers.add(name="PARCELS", color=colors.GREEN, linetype="CONTINUOUS", lineweight=25)
6363 self.doc.layers.add(name="ROADS", color=colors.BLACK, linetype="CONTINUOUS", lineweight=35)
@@ -71,6 +71,11 @@ def setup_layout_layers(self):
7171 lineweight=18)
7272 self.doc.layers.add(name="BUILDABLE", color=colors.GRAY, linetype="DASHDOT", lineweight=18)
7373
74+ def setup_route_layers(self):
75+ self.doc.layers.add(name="GRID", color=colors.BLACK)
76+ self.doc.layers.add(name="F-GRID", color=colors.YELLOW, linetype="DASHDOT")
77+ self.doc.layers.add(name="TEXT", color=colors.BLUE)
78+ self.doc.layers.add(name="PROFILE", color=colors.RED)
7479
7580 def setup_beacon_style(self, type_: str = "box", size: float = 1.0):
7681 size = size * self.scale
@@ -221,7 +226,6 @@ def add_greenspace(self, points: List[Tuple[float, float]], coords):
221226 hatch.set_pattern_fill('ANSI31', scale=0.5)
222227 hatch.paths.add_polyline_path(coords, is_closed=True)
223228
224-
225229 def add_label(self, text: str, x: float, y: float, angle: float = 0.0, height: float = 1.0):
226230 x = x * self.scale
227231 y = y * self.scale
@@ -241,21 +245,23 @@ def add_label(self, text: str, x: float, y: float, angle: float = 0.0, height: f
241245 align=TextEntityAlignment.MIDDLE_CENTER
242246 )
243247
244- def add_text(self, text: str, x: float, y: float, height: float = 1.0):
248+ def add_text(self, text: str, x: float, y: float, height: float = 1.0, rotation: float = 0.0, alignment=TextEntityAlignment.TOP_LEFT ):
245249 x = x * self.scale
246250 y = y * self.scale
247251 height = height * self.scale
248252
249253 """Add arbitrary text at given coordinates with optional rotation"""
250- text = self.msp.add_text(
254+ self.msp.add_text(
251255 text,
252256 dxfattribs={
253257 'layer': 'TEXT',
254258 'height': height,
255- 'style': 'STANDARD'
259+ 'style': 'STANDARD',
260+ "rotation": rotation,
256261 }
257262 ).set_placement(
258263 (x , y),
264+ align=alignment
259265 )
260266
261267 def draw_north_arrow(self, x: float, y: float, height: float = 100.0):
@@ -644,6 +650,27 @@ def add_spline(self, points: List[Tuple[float, float, float]], layer="CONTOUR_MI
644650 dxfattribs={'layer': layer}
645651 )
646652
653+ def add_grid_line(self, x1: float, y1: float, x2: float, y2: float):
654+ x1 = x1 * self.scale
655+ y1 = y1 * self.scale
656+ x2 = x2 * self.scale
657+ y2 = y2 * self.scale
658+
659+ self.msp.add_line((x1, y1), (x2, y2), dxfattribs={'layer': 'GRID'})
660+
661+ def add_f_grid_line(self, x1: float, y1: float, x2: float, y2: float):
662+ x1 = x1 * self.scale
663+ y1 = y1 * self.scale
664+ x2 = x2 * self.scale
665+ y2 = y2 * self.scale
666+
667+ self.msp.add_line((x1, y1), (x2, y2), dxfattribs={'layer': 'F-GRID'})
668+
669+ def add_profile(self, points: List[Tuple[float, float]]):
670+ points = [(x * self.scale, y * self.scale) for x, y in points]
671+
672+ self.msp.add_spline(points, dxfattribs={'layer': 'PROFILE'})
673+
647674 def toggle_layer(self, layer: str, state: bool):
648675 """Toggle the visibility of a layer"""
649676 layer_ = self.doc.layers.get(layer)
0 commit comments