From 462599b41d4e4121877f5f1f70cd65b07f350c09 Mon Sep 17 00:00:00 2001 From: n3040 Date: Thu, 28 Jul 2022 19:58:35 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E4=BA=86=E7=94=BB=E4=BB=A3?= =?UTF-8?q?=E8=A1=A8=E6=A1=A3=E8=B7=9D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- PWFile.py | 58 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 36 insertions(+), 22 deletions(-) diff --git a/PWFile.py b/PWFile.py index 95624d5..e1ad021 100644 --- a/PWFile.py +++ b/PWFile.py @@ -63,7 +63,9 @@ class SFile: tower_name = sep_entry[0] if tower_name in tower_dic: tower_dic[tower_name].forth_k = new_k # 更新耐张塔前侧k值。 - tower_dic[tower_name].forth_representive_span = new_reprtv_span # 更新耐张塔前侧k值。 + tower_dic[ + tower_name + ].forth_representive_span = new_reprtv_span # 更新耐张塔前侧k值。 last_k = tower_dic[tower_name].forth_k last_reprtv_span = tower_dic[tower_name].forth_representive_span continue @@ -114,6 +116,7 @@ class ColorEnume: tree_color_rgb = [240, 226, 81] ground_color_rgb = [82, 79, 254] span_text_color_rgb = [140, 245, 236] + representive_span_text_color_rgb = [255, 172, 75] # 读取Z文件,找到Z断面第一个点的坐标 @@ -145,9 +148,9 @@ def np2d_to_array(np2d): # 把2维numpy数组转换成cad可以用的数组 t = np.hstack((np2d, np.zeros((np2d.shape[0], 1)))).reshape(1, np2d.shape[0] * 3) return t[0] + @define class StringImpactExcel: - def read(self, wb, gaocha, span, tension): pos代表档距 = "F13" pos档距 = "L13" @@ -159,7 +162,6 @@ class StringImpactExcel: sheet.range(pos档距).value = span sheet.range(pos张力).value = tension string_length = sheet.range(pos总串长).value - # print(sheet.range("V25:V46").value) x = np.linspace(string_length, span, int(span / 5), endpoint=True) x[0] = sheet.range("E23").value x[1] = sheet.range("E24").value @@ -170,22 +172,24 @@ class StringImpactExcel: return (x, y) -def set_true_color(object, r_or_rgb_list, g, b): +def set_true_color(object, r_or_rgb_list, g=0, b=0): true_color = object.TrueColor - if type(r_or_rgb_list) == List: + if type(r_or_rgb_list) == List or type(r_or_rgb_list)==list: true_color.SetRGB(*r_or_rgb_list) else: true_color.SetRGB(r_or_rgb_list, g, b) object.TrueColor = true_color + @define class StringImpactExcelRecord: - from_tower_name:str="" - fo_tower_name:str="" - representive_span:float=0#代表档距 - span:float=0 - tension:float=0 - gaocha:float=0 + from_tower_name: str = "" + fo_tower_name: str = "" + representive_span: float = 0 # 代表档距 + span: float = 0 + tension: float = 0 + gaocha: float = 0 + @define class StringImpactPlate: @@ -195,8 +199,7 @@ class StringImpactPlate: _continouse_tension_excel: str _string_impact_curve_excel: str _cad: None - excel_record_list:List=[]#记录对excel的操作 - + excel_record_list: List = [] # 记录对excel的操作 def _find_target_tower_index(self, start_tower_name: str, tower_dict): # 从 start_tower_name开始,寻找一个耐张段 @@ -205,7 +208,6 @@ class StringImpactPlate: index.append(tower_key_list.index(start_tower_name)) can_start_find = False for tower_key in tower_key_list: - # index.append(start_tower_name.index(foo)) tower_info = tower_dict[tower_key] if tower_info.tower_name == start_tower_name: can_start_find = True @@ -279,17 +281,17 @@ class StringImpactPlate: ).reshape(len(x), 1) self._plot(cad, plot_x, plot_y) # 记录 - record=StringImpactExcelRecord() - record.from_tower_name=first_tower_info.tower_name - record.fo_tower_name=forth_tower_info.tower_name - record.span=span_of_first_tower - record.representive_span=first_tower_info.forth_representive_span - record.gaocha=gaocha_of_first_tower - record.tension=high_temperature_tension + record = StringImpactExcelRecord() + record.from_tower_name = first_tower_info.tower_name + record.fo_tower_name = forth_tower_info.tower_name + record.span = span_of_first_tower + record.representive_span = first_tower_info.forth_representive_span + record.gaocha = gaocha_of_first_tower + record.tension = high_temperature_tension self.excel_record_list.append(record) # 画右侧耐张塔的弧垂 draw_last_tower_key = tower_key_list[draw_tower_index[-1]] - last_tower_info = tower_dict[draw_last_tower_key]#最后一个塔位 + last_tower_info = tower_dict[draw_last_tower_key] # 最后一个塔位 back_reprtv_span = last_tower_info.back_representive_span back_tower_info = tower_dict[tower_key_list[draw_tower_index[-1] - 1]] gaocha_of_last_tower = ( @@ -395,6 +397,18 @@ class ContinuousPlate: continue if not last_tower_info: last_tower_info = tower_info + if draw_count == draw_count_limit: + # 画代表档距 + representive_span_text = f"{tower_info.back_representive_span:.0f}" + representive_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()), + 3, + ) + set_true_color(added_representive_span_text,ColorEnume.representive_span_text_color_rgb) if draw_count > draw_count_limit - 1: break foundation_low = tower_info.foundation_low