From d7e16069dbe57f8fb48864f7ec3206d2a69a7458 Mon Sep 17 00:00:00 2001 From: n3040 Date: Tue, 6 Feb 2024 10:00:43 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86autocad=E4=B8=8D?= =?UTF-8?q?=E8=83=BD=E8=AF=86=E5=88=AB//=E8=B7=AF=E5=BE=84=E7=9A=84bug?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cad.py | 10 ++++++++-- dem.py | 7 +++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/cad.py b/cad.py index 641bad9..d47a963 100644 --- a/cad.py +++ b/cad.py @@ -3,7 +3,6 @@ import os import subprocess - def convert_dxf_to_dwg(dxf_files: List[str]): cad_file_path = r"D:/Program Files/Cad2022/AutoCAD 2022/accoreconsole.exe" first_dwg_file = dxf_files[0] @@ -15,9 +14,16 @@ def convert_dxf_to_dwg(dxf_files: List[str]): new_dwg_name = f"{file_name_path}.dwg" if os.path.exists(new_dwg_name): os.remove(new_dwg_name) + new_dwg_name = new_dwg_name.replace("//", "/") f.write(f'saveas 2004 "{new_dwg_name}"\n') cmd = rf'"{cad_file_path}" /s "{script_path}" /i "{dxf}" /iso' - subprocess.call(cmd,stderr=subprocess.DEVNULL,stdin=subprocess.DEVNULL,stdout=subprocess.DEVNULL) + cmd = cmd.replace("//", "/") + subprocess.call( + cmd, + stderr=subprocess.DEVNULL, + stdin=subprocess.DEVNULL, + stdout=subprocess.DEVNULL, + ) def convert_dxf_to_dwg1(dxf_files: List[str]): diff --git a/dem.py b/dem.py index 5922644..2ca8bc8 100644 --- a/dem.py +++ b/dem.py @@ -378,7 +378,8 @@ class Dem: path_length = ( (point_x_s - point_x_e) ** 2 + (point_y_s - point_y_e) ** 2 ) ** 0.5 - dem_resolution = self._dem_resolution # dem的精度 + # dem_resolution = self._dem_resolution # dem的精度 + dem_resolution = 5 # TODO:设定为5m 1个点。 n = round(path_length / dem_resolution) # n = round(path_length / 5) @@ -397,7 +398,9 @@ class Dem: left_offset_y = side_width * math.sin(line_angel + math.pi / 2) left_offset_point_x = center_point_x + left_offset_x left_offset_point_y = center_point_y + left_offset_y - right_offset_point_x = center_point_x - left_offset_x # 向左偏移和向右偏移正好是相反的 + right_offset_point_x = ( + center_point_x - left_offset_x + ) # 向左偏移和向右偏移正好是相反的 right_offset_point_y = center_point_y - left_offset_y r = np.array( [