1.杆塔换成了青色。

This commit is contained in:
n3040 2022-08-13 17:06:36 +08:00
parent 2c0c013b73
commit 64973f9df5
1 changed files with 52 additions and 40 deletions

View File

@ -4,8 +4,6 @@ from collections import OrderedDict
import re import re
import attrs import attrs
import pandas as pd import pandas as pd
from attrs import define
from tkinter.messagebox import NO
import xlwings as xw import xlwings as xw
from Apyautocad import Apyautocad, APoint from Apyautocad import Apyautocad, APoint
import os import os
@ -51,7 +49,7 @@ class SFile:
if "首端转角号" in norm_line: if "首端转角号" in norm_line:
new_k = float(norm_line.split(":")[-1].replace("E", "e")) # 模板系数 new_k = float(norm_line.split(":")[-1].replace("E", "e")) # 模板系数
new_reprtv_span = float( new_reprtv_span = float(
re.findall("代表档距 : (\d+) 模板系数", norm_line)[0] re.findall(r"代表档距 : {2}(\d+) {3}模板系数", norm_line)[0]
) # 代表档距 ) # 代表档距
continue continue
if "塔号" in norm_line: if "塔号" in norm_line:
@ -59,7 +57,7 @@ class SFile:
if last_tower_name != "": if last_tower_name != "":
tower_dic[last_tower_name].is_tension_tower = True tower_dic[last_tower_name].is_tension_tower = True
continue continue
norm_entry = re.sub("\s+", ",", norm_line) norm_entry = re.sub(r"\s+", ",", norm_line)
sep_entry = norm_entry.split(",") sep_entry = norm_entry.split(",")
tower_name = sep_entry[0] tower_name = sep_entry[0]
if tower_name in tower_dic: if tower_name in tower_dic:
@ -256,7 +254,9 @@ class StringImpactPlate:
continouse_sheet.range("B69").value = forth_reprtv_span continouse_sheet.range("B69").value = forth_reprtv_span
high_temperature_tension = continouse_sheet.range("L69").value high_temperature_tension = continouse_sheet.range("L69").value
if first_tower_info.is_tension_tower: 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: if forth_tower_info.is_tension_tower:
forth_tower_fitting_length = 0 forth_tower_fitting_length = 0
else: else:
@ -285,7 +285,8 @@ class StringImpactPlate:
plot_x = (plate_origin[0] + x / 5).reshape(len(x), 1) plot_x = (plate_origin[0] + x / 5).reshape(len(x), 1)
plot_y = ( plot_y = (
plate_origin[1] 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) ).reshape(len(x), 1)
self._plot(cad, plot_x, plot_y) self._plot(cad, plot_x, plot_y)
# 记录 # 记录
@ -299,10 +300,12 @@ class StringImpactPlate:
self.excel_record_list.append(record) self.excel_record_list.append(record)
# 画右侧耐张塔的弧垂 # 画右侧耐张塔的弧垂
draw_last_tower_key = tower_key_list[draw_tower_index[-1]] 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: if last_tower_info.is_tension_tower:
back_reprtv_span = last_tower_info.back_representive_span 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: if back_tower_info.is_tension_tower:
back_tower_fitting_length = 0 back_tower_fitting_length = 0
else: else:
@ -318,7 +321,9 @@ class StringImpactPlate:
- (last_tower_info.tower_height - last_tower_info.foundation_low) - (last_tower_info.tower_height - last_tower_info.foundation_low)
- last_tower_info.altitude_off - 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( (x, y) = stringImpactExcel.read(
wb_string_impact, wb_string_impact,
gaocha_of_last_tower, gaocha_of_last_tower,
@ -343,7 +348,8 @@ class StringImpactPlate:
plot_last_tower_y = ( plot_last_tower_y = (
plate_origin[1] plate_origin[1]
+ accumulate_altitude_off * 2 + 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) ).reshape(len(x), 1)
plot_last_tower_vector = np2d_to_array( plot_last_tower_vector = np2d_to_array(
np.hstack((plot_last_tower_x, plot_last_tower_y)) np.hstack((plot_last_tower_x, plot_last_tower_y))
@ -422,17 +428,17 @@ class ContinuousPlate:
) )
if draw_count == draw_count_limit - 1: if draw_count == draw_count_limit - 1:
# 画代表档距 # 画代表档距
representive_span_text = f"{tower_info.back_representive_span:.0f}" represented_span_text = f"{tower_info.back_representive_span:.0f}"
representive_span_text_point = np.array( represented_span_text_point = np.array(
[(accu_mileage / 2) / 5 + 50, 1] [(accu_mileage / 2) / 5 + 50, 1]
) )
added_representive_span_text = cad.model.AddText( added_represented_span_text = cad.model.AddText(
representive_span_text, represented_span_text,
APoint(*representive_span_text_point.tolist()), APoint(*represented_span_text_point.tolist()),
3, 3,
) )
set_true_color( set_true_color(
added_representive_span_text, added_represented_span_text,
ColorEnume.representive_span_text_color_rgb, ColorEnume.representive_span_text_color_rgb,
) )
if is_first_tower: # 是否是开始画的第一个塔。 if is_first_tower: # 是否是开始画的第一个塔。
@ -441,18 +447,11 @@ class ContinuousPlate:
accu_altitude_off = ( accu_altitude_off = (
accu_altitude_off + tower_info.altitude_off accu_altitude_off + tower_info.altitude_off
) # 中心桩高程 ) # 中心桩高程
tower_start = APoint( np_tower_start = first_tower_point + np.array(
*( [
( accu_mileage / 5,
first_tower_point (accu_altitude_off - foundation_low) * 2,
+ np.array( ]
[
accu_mileage / 5,
(accu_altitude_off - foundation_low) * 2,
]
)
).tolist()
)
) )
tower_height = tower_info.tower_height tower_height = tower_info.tower_height
if tower_info.is_tension_tower: if tower_info.is_tension_tower:
@ -466,23 +465,35 @@ class ContinuousPlate:
np_tower_end = first_tower_point + np.array( np_tower_end = first_tower_point + np.array(
[ [
accu_mileage / 5, 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米 ) # 直线塔杆高只比悬垂挂点高3米
tower_end = APoint(*np_tower_end.tolist())
# 画杆高 # 画杆高
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( cad.model.AddText(
f"{tower_info.tower_name}", f"{tower_info.tower_name}",
APoint(*(np_tower_end + np.array([-5, 13])).tolist()), APoint(*(np_tower_end + np.array([-5, 13])).tolist()),
5, 5,
) )
if abs(math.floor(tower_info.tower_height)-tower_info.tower_height)<0.1:#考虑了半米呼高的情况 if (
draw_tower_height_str=f'{tower_info.tower_height:.0f}' abs(math.floor(tower_info.tower_height) - tower_info.tower_height)
< 0.1
): # 考虑了半米呼高的情况
draw_tower_height_str = f"{tower_info.tower_height:.0f}"
else: else:
draw_tower_height_str = f'{tower_info.tower_height:.1f}' draw_tower_height_str = f"{tower_info.tower_height:.1f}"
cad.model.AddText( cad.model.AddText(
f"{tower_info.tower_type}-{draw_tower_height_str}", f"{tower_info.tower_type}-{draw_tower_height_str}",
APoint(*(np_tower_end + np.array([-5, 5])).tolist()), APoint(*(np_tower_end + np.array([-5, 5])).tolist()),
@ -581,19 +592,20 @@ class ContinuousPlate:
def saveAs(self, save_to): def saveAs(self, save_to):
cad = self.cad cad = self.cad
doc = cad.doc
doc.SaveAs(save_to) doc.SaveAs(save_to)
@define @define
class ControlFile: 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 = "" _z_file_path: str = ""
_dwg_file_path: str = "" _dwg_file_path: str = ""
_from_tower_name: str = "" _from_tower_name: str = ""
_end_tower_name: str = "" _end_tower_name: str = ""
_consider_string_weight: bool = False _consider_string_weight: bool = False
_excel_string_weight_path: str = "" _excel_string_weight_path: str = ""
_excel_continouse_path: str = "" _excel_continuous_path: str = ""
_s_file_path: str = "" _s_file_path: str = ""
_dir_prefix: str = "" _dir_prefix: str = ""
_z_file_name: str = "" _z_file_name: str = ""
@ -612,7 +624,7 @@ class ControlFile:
if pf_dict["是否考虑耐张串影响"] == "": if pf_dict["是否考虑耐张串影响"] == "":
self._consider_string_weight = True self._consider_string_weight = True
self._excel_string_weight_path = pf_dict["计算耐张串影响用表格"] 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._z_file_path = os.path.join(dir_prefix, pf_dict["Z文件"])
self._dwg_file_path = os.path.join(dir_prefix, pf_dict["DWG文件"]) self._dwg_file_path = os.path.join(dir_prefix, pf_dict["DWG文件"])
self._s_file_path = os.path.join(dir_prefix, pf_dict["S文件"]) self._s_file_path = os.path.join(dir_prefix, pf_dict["S文件"])
@ -632,7 +644,7 @@ class ControlFile:
self._dwg_file_path, self._dwg_file_path,
self._s_file_path, self._s_file_path,
self._from_tower_name, self._from_tower_name,
self._excel_continouse_path, self._excel_continuous_path,
self._excel_string_weight_path, self._excel_string_weight_path,
continousePlate.cad, continousePlate.cad,
) )