@@ -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
0 commit comments