From 64973f9df5bad345f0dadf7f7a84fbbdc53bc285 Mon Sep 17 00:00:00 2001 From: n3040 Date: Sat, 13 Aug 2022 17:06:36 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=9D=86=E5=A1=94=E6=8D=A2=E6=88=90=E4=BA=86?= =?UTF-8?q?=E9=9D=92=E8=89=B2=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PWFile.py | 92 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 52 insertions(+), 40 deletions(-) diff --git a/PWFile.py b/PWFile.py index fea1a94..0d01661 100644 --- a/PWFile.py +++ b/PWFile.py @@ -4,8 +4,6 @@ from collections import OrderedDict import re import attrs import pandas as pd -from attrs import define -from tkinter.messagebox import NO import xlwings as xw from Apyautocad import Apyautocad, APoint import os @@ -51,7 +49,7 @@ class SFile: if "首端转角号" in norm_line: new_k = float(norm_line.split(":")[-1].replace("E", "e")) # 模板系数 new_reprtv_span = float( - re.findall("代表档距 : (\d+) 模板系数", norm_line)[0] + re.findall(r"代表档距 : {2}(\d+) {3}模板系数", norm_line)[0] ) # 代表档距 continue if "塔号" in norm_line: @@ -59,7 +57,7 @@ class SFile: if last_tower_name != "": tower_dic[last_tower_name].is_tension_tower = True continue - norm_entry = re.sub("\s+", ",", norm_line) + norm_entry = re.sub(r"\s+", ",", norm_line) sep_entry = norm_entry.split(",") tower_name = sep_entry[0] if tower_name in tower_dic: @@ -256,7 +254,9 @@ class StringImpactPlate: continouse_sheet.range("B69").value = forth_reprtv_span high_temperature_tension = continouse_sheet.range("L69").value if first_tower_info.is_tension_tower: - forth_tower_info: SEntry = tower_dict[tower_key_list[draw_tower_index[0] + 1]] + forth_tower_info: SEntry = tower_dict[ + tower_key_list[draw_tower_index[0] + 1] + ] if forth_tower_info.is_tension_tower: forth_tower_fitting_length = 0 else: @@ -285,7 +285,8 @@ class StringImpactPlate: plot_x = (plate_origin[0] + x / 5).reshape(len(x), 1) plot_y = ( plate_origin[1] - + (first_tower_info.tower_height - first_tower_info.foundation_low + y) * 2 + + (first_tower_info.tower_height - first_tower_info.foundation_low + y) + * 2 ).reshape(len(x), 1) self._plot(cad, plot_x, plot_y) # 记录 @@ -299,10 +300,12 @@ class StringImpactPlate: self.excel_record_list.append(record) # 画右侧耐张塔的弧垂 draw_last_tower_key = tower_key_list[draw_tower_index[-1]] - last_tower_info:SEntry = tower_dict[draw_last_tower_key] # 最后一个塔位 + last_tower_info: SEntry = tower_dict[draw_last_tower_key] # 最后一个塔位 if last_tower_info.is_tension_tower: back_reprtv_span = last_tower_info.back_representive_span - back_tower_info: SEntry = tower_dict[tower_key_list[draw_tower_index[-1] - 1]] + back_tower_info: SEntry = tower_dict[ + tower_key_list[draw_tower_index[-1] - 1] + ] if back_tower_info.is_tension_tower: back_tower_fitting_length = 0 else: @@ -318,7 +321,9 @@ class StringImpactPlate: - (last_tower_info.tower_height - last_tower_info.foundation_low) - last_tower_info.altitude_off ) - span_of_last_tower = last_tower_info.mileage_in_s - back_tower_info.mileage_in_s + span_of_last_tower = ( + last_tower_info.mileage_in_s - back_tower_info.mileage_in_s + ) (x, y) = stringImpactExcel.read( wb_string_impact, gaocha_of_last_tower, @@ -343,7 +348,8 @@ class StringImpactPlate: plot_last_tower_y = ( plate_origin[1] + accumulate_altitude_off * 2 - + (last_tower_info.tower_height - last_tower_info.foundation_low + y) * 2 + + (last_tower_info.tower_height - last_tower_info.foundation_low + y) + * 2 ).reshape(len(x), 1) plot_last_tower_vector = np2d_to_array( np.hstack((plot_last_tower_x, plot_last_tower_y)) @@ -422,17 +428,17 @@ class ContinuousPlate: ) if draw_count == draw_count_limit - 1: # 画代表档距 - representive_span_text = f"{tower_info.back_representive_span:.0f}" - representive_span_text_point = np.array( + represented_span_text = f"{tower_info.back_representive_span:.0f}" + represented_span_text_point = np.array( [(accu_mileage / 2) / 5 + 50, 1] ) - added_representive_span_text = cad.model.AddText( - representive_span_text, - APoint(*representive_span_text_point.tolist()), + added_represented_span_text = cad.model.AddText( + represented_span_text, + APoint(*represented_span_text_point.tolist()), 3, ) set_true_color( - added_representive_span_text, + added_represented_span_text, ColorEnume.representive_span_text_color_rgb, ) if is_first_tower: # 是否是开始画的第一个塔。 @@ -441,18 +447,11 @@ class ContinuousPlate: accu_altitude_off = ( accu_altitude_off + tower_info.altitude_off ) # 中心桩高程 - tower_start = APoint( - *( - ( - first_tower_point - + np.array( - [ - accu_mileage / 5, - (accu_altitude_off - foundation_low) * 2, - ] - ) - ).tolist() - ) + np_tower_start = first_tower_point + np.array( + [ + accu_mileage / 5, + (accu_altitude_off - foundation_low) * 2, + ] ) tower_height = tower_info.tower_height if tower_info.is_tension_tower: @@ -466,23 +465,35 @@ class ContinuousPlate: np_tower_end = first_tower_point + np.array( [ accu_mileage / 5, - (accu_altitude_off + tower_height - foundation_low-fitting_length_dict[tower_info.fitting]+3) * 2, + ( + accu_altitude_off + + tower_height + - foundation_low + - fitting_length_dict[tower_info.fitting] + + 3 + ) + * 2, ] - )#直线塔杆高只比悬垂挂点高3米 - - tower_end = APoint(*np_tower_end.tolist()) + ) # 直线塔杆高只比悬垂挂点高3米 # 画杆高 - cad.model.AddLine(tower_start, tower_end) + tower_pole = cad.model.AddPolyLine( + np2d_to_array(np.vstack((np_tower_start, np_tower_end))) + ) + tower_pole.SetWidth(0, 0.8, 0.8) + set_true_color(tower_pole, 0, 255, 255) # 画塔名和呼高 cad.model.AddText( f"{tower_info.tower_name}", APoint(*(np_tower_end + np.array([-5, 13])).tolist()), 5, ) - if abs(math.floor(tower_info.tower_height)-tower_info.tower_height)<0.1:#考虑了半米呼高的情况 - draw_tower_height_str=f'{tower_info.tower_height:.0f}' + if ( + abs(math.floor(tower_info.tower_height) - tower_info.tower_height) + < 0.1 + ): # 考虑了半米呼高的情况 + draw_tower_height_str = f"{tower_info.tower_height:.0f}" else: - draw_tower_height_str = f'{tower_info.tower_height:.1f}' + draw_tower_height_str = f"{tower_info.tower_height:.1f}" cad.model.AddText( f"{tower_info.tower_type}-{draw_tower_height_str}", APoint(*(np_tower_end + np.array([-5, 5])).tolist()), @@ -581,19 +592,20 @@ class ContinuousPlate: def saveAs(self, save_to): cad = self.cad + doc = cad.doc doc.SaveAs(save_to) @define class ControlFile: - _z_excel_file_path: bool = attrs.field(init=True, kw_only=False) + _z_excel_file_path: str = attrs.field(init=True, kw_only=False) _z_file_path: str = "" _dwg_file_path: str = "" _from_tower_name: str = "" _end_tower_name: str = "" _consider_string_weight: bool = False _excel_string_weight_path: str = "" - _excel_continouse_path: str = "" + _excel_continuous_path: str = "" _s_file_path: str = "" _dir_prefix: str = "" _z_file_name: str = "" @@ -612,7 +624,7 @@ class ControlFile: if pf_dict["是否考虑耐张串影响"] == "是": self._consider_string_weight = True self._excel_string_weight_path = pf_dict["计算耐张串影响用表格"] - self._excel_continouse_path = pf_dict["计算连续档用表格"] + self._excel_continuous_path = pf_dict["计算连续档用表格"] self._z_file_path = os.path.join(dir_prefix, pf_dict["Z文件"]) self._dwg_file_path = os.path.join(dir_prefix, pf_dict["DWG文件"]) self._s_file_path = os.path.join(dir_prefix, pf_dict["S文件"]) @@ -632,7 +644,7 @@ class ControlFile: self._dwg_file_path, self._s_file_path, self._from_tower_name, - self._excel_continouse_path, + self._excel_continuous_path, self._excel_string_weight_path, continousePlate.cad, )