Skip to content

Commit 59369b0

Browse files
committed
main
1 parent fe0cda7 commit 59369b0

3 files changed

Lines changed: 55 additions & 1 deletion

File tree

cadastral.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,12 +155,32 @@ def draw_title_block(self):
155155
area=f"AREA :- {self.parcels[0].area} SQ.METRES",
156156
origin=f"ORIGIN :- {self.origin.upper()}")
157157

158+
def draw_footer_boxes(self):
159+
if len(self.footers) == 0:
160+
return
161+
162+
x_min = self._frame_coords[0]
163+
y_min = self._frame_coords[1]
164+
x_max = self._frame_coords[2]
165+
y_max = self._frame_coords[3]
166+
167+
box_width = (x_max - x_min) / len(self.footers)
168+
box_height = (y_max - y_min) * 0.25
169+
170+
for i, footer in enumerate(self.footers):
171+
x1 = x_min + i * box_width
172+
x2 = x1 + box_width
173+
y1 = y_min
174+
y2 = y1 + box_height
175+
self._drawer.draw_footer_box(html_to_mtext(footer), x1, y1, x2, y2, self.footer_scale)
176+
158177
def draw(self):
159178
# Draw elements
160179
self.draw_beacons()
161180
self.draw_parcels()
162181
self.draw_frames()
163182
self.draw_title_block()
183+
self.draw_footer_boxes()
164184

165185
def save_dxf(self, file_path: str):
166186
self._drawer.save_dxf(file_path)

dxf.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ def _setup_layers(self):
4242
('TITLE_BLOCK', 7), # White
4343
('TRAVERSE', 6), # Magenta
4444
('SPOT_HEIGHTS', 3), # Green
45+
("FOOTER", 7), # Black/White
4546
]
4647

4748
for name, color in layers:
@@ -299,6 +300,38 @@ def draw_title_block(self, text: str, x: float, y: float, width: float, title_he
299300
origin_mtext.dxf.width = width
300301
origin_mtext.set_location((x, graphical_min_y - (1 * self.scale)))
301302

303+
def draw_footer_box(self, text: str, min_x, min_y, max_x, max_y, font_size: float = 1.0):
304+
font_size = font_size * self.scale
305+
min_x = min_x * self.scale
306+
min_y = min_y * self.scale
307+
max_x = max_x * self.scale
308+
max_y = max_y * self.scale
309+
310+
"""Draw a rectangle given min and max coordinates"""
311+
self.msp.add_lwpolyline([
312+
(min_x, min_y),
313+
(max_x, min_y),
314+
(max_x, max_y),
315+
(min_x, max_y)
316+
], close=True, dxfattribs={
317+
'layer': 'FOOTER',
318+
})
319+
320+
# add text inside box
321+
footer_mtext = self.msp.add_mtext(
322+
text=text,
323+
dxfattribs={
324+
'layer': 'FOOTER',
325+
'style': 'SURVEY_TEXT',
326+
# 'height': (max_y - min_y) * 0.8,
327+
}
328+
)
329+
footer_mtext.dxf.attachment_point = ezdxf.enums.MTextEntityAlignment.TOP_LEFT
330+
footer_mtext.dxf.width = (max_x - min_x) * 0.9
331+
# set location at top-left corner with some padding
332+
footer_mtext.set_location((min_x + (0.05 * (max_x - min_x)), max_y - (0.1 * (max_y - min_y))))
333+
footer_mtext.dxf.char_height = font_size
334+
302335

303336
def draw_frame(self, min_x, min_y, max_x, max_y):
304337
min_x = min_x * self.scale

models/plan.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,8 @@ class PlanProps(BaseModel):
110110
page_orientation: PageOrientation = PageOrientation.PORTRAIT
111111
topographic_setting: Optional[TopographicSettingProps] = None
112112
topographic_boundary: Optional[TopographicBoundaryProps] = None
113-
notes: List[str] = []
113+
footers: List[str] = []
114+
footer_scale: float = 0.5
114115

115116
def get_drawing_scale(self):
116117
if not self.scale:

0 commit comments

Comments
 (0)