1.塔呼高可以有小数。
This commit is contained in:
parent
0dc1f3e153
commit
2c0c013b73
249
PWFile.py
249
PWFile.py
|
|
@ -1,3 +1,4 @@
|
|||
import math
|
||||
import os.path
|
||||
from collections import OrderedDict
|
||||
import re
|
||||
|
|
@ -20,14 +21,14 @@ class SEntry:
|
|||
tower_height: float = 0
|
||||
tower_type: str = ""
|
||||
mileage_in_s: int = 0
|
||||
back_k: float = 0
|
||||
forth_k: float = 0
|
||||
back_k: float = 0 # 杆塔后侧的k值
|
||||
forth_k: float = 0 # 杆塔前侧的k值
|
||||
altitude_off: float = 0 # 中心桩高差
|
||||
foundation_low: float = 0 # 基降
|
||||
fitting: str = "" # 金具
|
||||
is_tension_tower: bool = False
|
||||
back_representive_span: float = 0 # 代表档距
|
||||
forth_representive_span: float = 0 # 代表档距
|
||||
is_tension_tower: bool = False # 是否为耐张塔
|
||||
back_representive_span: float = 0 # 后侧代表档距
|
||||
forth_representive_span: float = 0 # 前侧代表档距
|
||||
|
||||
|
||||
class SFile:
|
||||
|
|
@ -65,7 +66,7 @@ class SFile:
|
|||
tower_dic[tower_name].forth_k = new_k # 更新耐张塔前侧k值。
|
||||
tower_dic[
|
||||
tower_name
|
||||
].forth_representive_span = new_reprtv_span # 更新耐张塔前侧k值。
|
||||
].forth_representive_span = new_reprtv_span # 更新耐张塔前侧代表档距。
|
||||
last_k = tower_dic[tower_name].forth_k
|
||||
last_reprtv_span = tower_dic[tower_name].forth_representive_span
|
||||
continue
|
||||
|
|
@ -91,7 +92,7 @@ class SFile:
|
|||
|
||||
|
||||
@define
|
||||
class Fitting:
|
||||
class Fitting: # 金具
|
||||
fitting_length_dic = {}
|
||||
|
||||
def __init__(self, fitting_file_path):
|
||||
|
|
@ -140,7 +141,7 @@ def deduce_fit_db_from_cad_path(cad_file_path):
|
|||
return os.path.join(dwg_file_name[0], "Fit.db")
|
||||
|
||||
|
||||
def curve_fun(x, span, k, gaocha):
|
||||
def curve_fun(x, span, k, gaocha): # 弧垂公式
|
||||
return x * gaocha / span - x * (span - x) * k
|
||||
|
||||
|
||||
|
|
@ -250,102 +251,104 @@ class StringImpactPlate:
|
|||
stringImpactExcel = StringImpactExcel()
|
||||
sleep(1)
|
||||
draw_first_tower_key = tower_key_list[draw_tower_index[0]]
|
||||
first_tower_info = tower_dict[draw_first_tower_key]
|
||||
first_tower_info: SEntry = tower_dict[draw_first_tower_key]
|
||||
forth_reprtv_span = first_tower_info.forth_representive_span
|
||||
continouse_sheet.range("B69").value = forth_reprtv_span
|
||||
high_temperature_tension = continouse_sheet.range("L69").value
|
||||
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:
|
||||
forth_tower_fitting_length = fitting.fitting_length_dic[
|
||||
forth_tower_info.fitting
|
||||
]
|
||||
gaocha_of_first_tower = (
|
||||
(
|
||||
forth_tower_info.tower_height
|
||||
- forth_tower_info.foundation_low
|
||||
- forth_tower_fitting_length
|
||||
if first_tower_info.is_tension_tower:
|
||||
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:
|
||||
forth_tower_fitting_length = fitting.fitting_length_dic[
|
||||
forth_tower_info.fitting
|
||||
]
|
||||
gaocha_of_first_tower = (
|
||||
(
|
||||
forth_tower_info.tower_height
|
||||
- forth_tower_info.foundation_low
|
||||
- forth_tower_fitting_length
|
||||
)
|
||||
- (first_tower_info.tower_height - first_tower_info.foundation_low)
|
||||
+ forth_tower_info.altitude_off
|
||||
)
|
||||
- (first_tower_info.tower_height - first_tower_info.foundation_low)
|
||||
+ forth_tower_info.altitude_off
|
||||
)
|
||||
span_of_first_tower = (
|
||||
forth_tower_info.mileage_in_s - first_tower_info.mileage_in_s
|
||||
)
|
||||
(x, y) = stringImpactExcel.read(
|
||||
wb_string_impact,
|
||||
gaocha_of_first_tower,
|
||||
span_of_first_tower,
|
||||
high_temperature_tension,
|
||||
)
|
||||
# TODO: 没有考虑断面中间有耐张塔的情况
|
||||
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
|
||||
).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
|
||||
self.excel_record_list.append(record)
|
||||
span_of_first_tower = (
|
||||
forth_tower_info.mileage_in_s - first_tower_info.mileage_in_s
|
||||
)
|
||||
(x, y) = stringImpactExcel.read(
|
||||
wb_string_impact,
|
||||
gaocha_of_first_tower,
|
||||
span_of_first_tower,
|
||||
high_temperature_tension,
|
||||
)
|
||||
# TODO: 没有考虑断面中间有耐张塔的情况
|
||||
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
|
||||
).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
|
||||
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] # 最后一个塔位
|
||||
back_reprtv_span = last_tower_info.back_representive_span
|
||||
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:
|
||||
back_tower_fitting_length = fitting.fitting_length_dic[
|
||||
back_tower_info.fitting
|
||||
]
|
||||
gaocha_of_last_tower = (
|
||||
(
|
||||
back_tower_info.tower_height
|
||||
- back_tower_info.foundation_low
|
||||
- back_tower_fitting_length
|
||||
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]]
|
||||
if back_tower_info.is_tension_tower:
|
||||
back_tower_fitting_length = 0
|
||||
else:
|
||||
back_tower_fitting_length = fitting.fitting_length_dic[
|
||||
back_tower_info.fitting
|
||||
]
|
||||
gaocha_of_last_tower = (
|
||||
(
|
||||
back_tower_info.tower_height
|
||||
- back_tower_info.foundation_low
|
||||
- back_tower_fitting_length
|
||||
)
|
||||
- (last_tower_info.tower_height - last_tower_info.foundation_low)
|
||||
- last_tower_info.altitude_off
|
||||
)
|
||||
- (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
|
||||
(x, y) = stringImpactExcel.read(
|
||||
wb_string_impact,
|
||||
gaocha_of_last_tower,
|
||||
span_of_last_tower,
|
||||
high_temperature_tension,
|
||||
)
|
||||
plot_last_tower_x = (
|
||||
plate_origin[0]
|
||||
+ (
|
||||
tower_dict[tower_key_list[draw_tower_index[-1]]].mileage_in_s
|
||||
- tower_dict[tower_key_list[draw_tower_index[0]]].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,
|
||||
span_of_last_tower,
|
||||
high_temperature_tension,
|
||||
)
|
||||
/ 5
|
||||
- x / 5 # 从右往左画
|
||||
).reshape(len(x), 1)
|
||||
accumulate_altitude_off = np.sum(
|
||||
[
|
||||
tower_dict[tower_key_list[bar]].altitude_off
|
||||
for bar in range(draw_tower_index[0] + 1, draw_tower_index[-1] + 1)
|
||||
]
|
||||
)
|
||||
plot_last_tower_y = (
|
||||
plate_origin[1]
|
||||
+ accumulate_altitude_off * 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))
|
||||
)
|
||||
self._plot(cad, plot_last_tower_x, plot_last_tower_y)
|
||||
plot_last_tower_x = (
|
||||
plate_origin[0]
|
||||
+ (
|
||||
tower_dict[tower_key_list[draw_tower_index[-1]]].mileage_in_s
|
||||
- tower_dict[tower_key_list[draw_tower_index[0]]].mileage_in_s
|
||||
)
|
||||
/ 5
|
||||
- x / 5 # 从右往左画
|
||||
).reshape(len(x), 1)
|
||||
accumulate_altitude_off = np.sum(
|
||||
[
|
||||
tower_dict[tower_key_list[bar]].altitude_off
|
||||
for bar in range(draw_tower_index[0] + 1, draw_tower_index[-1] + 1)
|
||||
]
|
||||
)
|
||||
plot_last_tower_y = (
|
||||
plate_origin[1]
|
||||
+ accumulate_altitude_off * 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))
|
||||
)
|
||||
self._plot(cad, plot_last_tower_x, plot_last_tower_y)
|
||||
|
||||
def draw(self):
|
||||
if self._cad:
|
||||
|
|
@ -376,7 +379,7 @@ class ContinuousPlate:
|
|||
s_file.open(s_file_path)
|
||||
dwg_file_path = self._dwg_file_path
|
||||
with Apyautocad(
|
||||
create_if_not_exists=True, visible=False, auto_close=False
|
||||
create_if_not_exists=True, visible=True, auto_close=False
|
||||
) as cad:
|
||||
self.cad = cad
|
||||
doc = cad.app.Documents.Open(dwg_file_path)
|
||||
|
|
@ -409,6 +412,14 @@ class ContinuousPlate:
|
|||
continue
|
||||
if not last_tower_info:
|
||||
last_tower_info = tower_info
|
||||
if draw_count > draw_count_limit - 1:
|
||||
break
|
||||
foundation_low = tower_info.foundation_low
|
||||
accu_mileage = (
|
||||
accu_mileage
|
||||
+ tower_info.mileage_in_s
|
||||
- last_tower_info.mileage_in_s
|
||||
)
|
||||
if draw_count == draw_count_limit - 1:
|
||||
# 画代表档距
|
||||
representive_span_text = f"{tower_info.back_representive_span:.0f}"
|
||||
|
|
@ -424,15 +435,7 @@ class ContinuousPlate:
|
|||
added_representive_span_text,
|
||||
ColorEnume.representive_span_text_color_rgb,
|
||||
)
|
||||
if draw_count > draw_count_limit - 1:
|
||||
break
|
||||
foundation_low = tower_info.foundation_low
|
||||
accu_mileage = (
|
||||
accu_mileage
|
||||
+ tower_info.mileage_in_s
|
||||
- last_tower_info.mileage_in_s
|
||||
)
|
||||
if is_first_tower:
|
||||
if is_first_tower: # 是否是开始画的第一个塔。
|
||||
accu_altitude_off = 0
|
||||
else:
|
||||
accu_altitude_off = (
|
||||
|
|
@ -452,12 +455,21 @@ class ContinuousPlate:
|
|||
)
|
||||
)
|
||||
tower_height = tower_info.tower_height
|
||||
np_tower_end = first_tower_point + np.array(
|
||||
[
|
||||
accu_mileage / 5,
|
||||
(accu_altitude_off + tower_height - foundation_low) * 2,
|
||||
]
|
||||
)
|
||||
if tower_info.is_tension_tower:
|
||||
np_tower_end = first_tower_point + np.array(
|
||||
[
|
||||
accu_mileage / 5,
|
||||
(accu_altitude_off + tower_height - foundation_low) * 2,
|
||||
]
|
||||
)
|
||||
else:
|
||||
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,
|
||||
]
|
||||
)#直线塔杆高只比悬垂挂点高3米
|
||||
|
||||
tower_end = APoint(*np_tower_end.tolist())
|
||||
# 画杆高
|
||||
cad.model.AddLine(tower_start, tower_end)
|
||||
|
|
@ -467,8 +479,12 @@ class ContinuousPlate:
|
|||
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}'
|
||||
else:
|
||||
draw_tower_height_str = f'{tower_info.tower_height:.1f}'
|
||||
cad.model.AddText(
|
||||
f"{tower_info.tower_type}-{tower_info.tower_height}",
|
||||
f"{tower_info.tower_type}-{draw_tower_height_str}",
|
||||
APoint(*(np_tower_end + np.array([-5, 5])).tolist()),
|
||||
5,
|
||||
)
|
||||
|
|
@ -623,5 +639,12 @@ class ControlFile:
|
|||
string_impact_plate.draw()
|
||||
cad = continousePlate.cad
|
||||
cad.doc.SaveAs(self.get_zt_dwg_file_path())
|
||||
# # 画完后再打开
|
||||
# cad = None
|
||||
# continousePlate = None
|
||||
# with Apyautocad(
|
||||
# create_if_not_exists=True, visible=True, auto_close=False
|
||||
# ) as cad:
|
||||
# cad.app.Documents.Open(self.get_zt_dwg_file_path())
|
||||
if self._close_cad_document:
|
||||
cad.doc.Close(False)
|
||||
|
|
|
|||
4
gui.py
4
gui.py
|
|
@ -42,12 +42,12 @@ class MainWindow(QMainWindow, Ui_mainWindow):
|
|||
self.statusBar().showMessage(
|
||||
f"{datetime.datetime.now()} Finished.", 8000
|
||||
)
|
||||
QMessageBox.information(self, "提示", "断面图已生成。")
|
||||
|
||||
file_info = QFileInfo(z_control_file_path)
|
||||
self._setting.setValue(
|
||||
"last_working_directory", file_info.absoluteDir().absolutePath()
|
||||
)
|
||||
zfile_name = file_info.baseName()
|
||||
QMessageBox.information(self, "提示", zfile_name + "断面图已生成。")
|
||||
|
||||
def _cBCloseCadDocClicked(self):
|
||||
self._setting.setValue("close_cad", self.cBCloseCadDoc.isChecked())
|
||||
|
|
|
|||
Loading…
Reference in New Issue