|
10 | 10 | import uuid |
11 | 11 | import zipfile |
12 | 12 | from upload import upload_file |
13 | | -from ezdxf import bbox |
| 13 | +from ezdxf import bbox, colors |
| 14 | + |
14 | 15 |
|
15 | 16 |
|
16 | 17 | class SurveyDXFManager: |
@@ -49,9 +50,9 @@ def _setup_layers(self): |
49 | 50 | for name, color in layers: |
50 | 51 | self.doc.layers.add(name=name, color=color) |
51 | 52 |
|
52 | | - # self.doc.layers.new('CONTOURS_MAJOR', dxfattribs={'color': colors.RED, 'lineweight': 50}) |
53 | | - # self.doc.layers.new('CONTOURS_MINOR', dxfattribs={'color': colors.BLUE, 'lineweight': 25}) |
54 | | - # self.doc.layers.new('CONTOUR_LABELS', dxfattribs={'color': colors.BLACK}) |
| 53 | + self.doc.layers.new('CONTOURS_MAJOR', dxfattribs={'color': colors.RED}) |
| 54 | + self.doc.layers.new('CONTOURS_MINOR', dxfattribs={'true_color': ezdxf.colors.rgb2int((127, 31, 0))}) |
| 55 | + self.doc.layers.new('CONTOUR_LABELS', dxfattribs={'color': colors.BLACK}) |
55 | 56 | # self.doc.layers.new("TIN_TRIANGLES", dxfattribs={'color': colors.CYAN, 'lineweight': 10}) |
56 | 57 |
|
57 | 58 | def setup_beacon_style(self, type_: str = "box", size: float = 1.0): |
@@ -394,7 +395,7 @@ def draw_topo_point(self, x: float, y: float, z: float = 0, label: str = None, t |
394 | 395 | dxfattribs={ |
395 | 396 | 'layer': 'SPOT_HEIGHTS', |
396 | 397 | 'height': text_height, |
397 | | - 'style': 'SURVEY_TEXT', |
| 398 | + 'style': 'Standard', |
398 | 399 | 'color': 7 # Black/White |
399 | 400 | } |
400 | 401 | ).set_placement( |
@@ -458,27 +459,27 @@ def save_dwg(self, dxf_filepath: str, filepath: str = None): |
458 | 459 | odafc.convert(dxf_filepath, filepath) |
459 | 460 |
|
460 | 461 | def save(self, paper_size: str = "A4", orientation: str = "portrait"): |
461 | | - # with tempfile.TemporaryDirectory() as tmpdir: |
462 | | - filename = self.get_filename() |
463 | | - dxf_path = os.path.join("", f"{filename}.dxf") |
464 | | - # dwg_path = os.path.join(tmpdir, f"{filename}.dwg") |
465 | | - pdf_path = os.path.join("", f"{filename}.pdf") |
466 | | - zip_path = os.path.join("", f"{filename}.zip") |
467 | | - |
468 | | - self.save_dxf(dxf_path) |
469 | | - # self.save_dwg(dxf_path, dwg_path) |
470 | | - self.save_pdf(pdf_path, paper_size=paper_size, orientation=orientation) |
471 | | - |
472 | | - # Create a ZIP file containing all three formats |
473 | | - with zipfile.ZipFile(zip_path, "w") as zipf: |
474 | | - zipf.write(dxf_path, os.path.basename(dxf_path)) |
475 | | - # zipf.write(dwg_path, os.path.basename(dwg_path)) |
476 | | - zipf.write(pdf_path, os.path.basename(pdf_path)) |
477 | | - |
478 | | - url = upload_file(zip_path, folder="survey_plans", file_name=filename) |
479 | | - if url is None: |
480 | | - raise Exception("Upload failed") |
481 | | - return url |
| 462 | + with tempfile.TemporaryDirectory() as tmpdir: |
| 463 | + filename = self.get_filename() |
| 464 | + dxf_path = os.path.join("", f"{filename}.dxf") |
| 465 | + dwg_path = os.path.join(tmpdir, f"{filename}.dwg") |
| 466 | + pdf_path = os.path.join("", f"{filename}.pdf") |
| 467 | + zip_path = os.path.join("", f"{filename}.zip") |
| 468 | + |
| 469 | + self.save_dxf(dxf_path) |
| 470 | + self.save_dwg(dxf_path, dwg_path) |
| 471 | + self.save_pdf(pdf_path, paper_size=paper_size, orientation=orientation) |
| 472 | + |
| 473 | + # Create a ZIP file containing all three formats |
| 474 | + with zipfile.ZipFile(zip_path, "w") as zipf: |
| 475 | + zipf.write(dxf_path, os.path.basename(dxf_path)) |
| 476 | + zipf.write(dwg_path, os.path.basename(dwg_path)) |
| 477 | + zipf.write(pdf_path, os.path.basename(pdf_path)) |
| 478 | + |
| 479 | + url = upload_file(zip_path, folder="survey_plans", file_name=filename) |
| 480 | + if url is None: |
| 481 | + raise Exception("Upload failed") |
| 482 | + return url |
482 | 483 |
|
483 | 484 | # def add_topo_point(self, x: float, y: float, z: float, label: str = None, text_height: float = 1.0): |
484 | 485 | # self.msp.add_blockref( |
|
0 commit comments