1.完成了画双侧耐张串下压后弧垂的功能。

This commit is contained in:
n3040 2022-07-25 03:47:28 +08:00
parent 0555479ab4
commit a5a4e412ec
1 changed files with 119 additions and 65 deletions

184
main.py
View File

@ -1,6 +1,6 @@
from tkinter.messagebox import NO from tkinter.messagebox import NO
import xlwings as xw import xlwings as xw
from PWFile import SFile, Fitting,ColorEnume from PWFile import SFile, Fitting, ColorEnume
from Apyautocad import Apyautocad, APoint from Apyautocad import Apyautocad, APoint
import os import os
import re import re
@ -58,9 +58,11 @@ class StringImpactExcel:
# print(sheet.range("V25:V46").value) # print(sheet.range("V25:V46").value)
x = np.linspace(string_length, span, int(span / 5), endpoint=True) x = np.linspace(string_length, span, int(span / 5), endpoint=True)
x[0] = sheet.range("E23").value x[0] = sheet.range("E23").value
x[1]=sheet.range("E24").value x[1] = sheet.range("E24").value
sheet.range(f"E25:E{25+len(x)-3}").value = x[2:].reshape(len(x[2:]), 1) sheet.range(f"E25:E{25+len(x)-3}").value = x[2:].reshape(len(x[2:]), 1)
y = np.array(sheet.range(f"V23:V{23+len(x)-1}").value)/2#表格是乘以了2的为了和x保持一致没有乘比例。 y = (
np.array(sheet.range(f"V23:V{23+len(x)-1}").value) / 2
) # 表格是乘以了2的为了和x保持一致没有乘比例。
return (x, y) return (x, y)
@ -74,24 +76,50 @@ def set_true_color(object, r, g, b):
class StringImpactPlate: class StringImpactPlate:
_dwg_file_path: str _dwg_file_path: str
_s_file_path: str _s_file_path: str
_draw_tower_name: List[str] _draw_start_tower_name: str
# _tension_section:int#耐张段数量 # _tension_section:int#耐张段数量
_continouse_tension_excel: str _continouse_tension_excel: str
_string_impact_curve_excel: str _string_impact_curve_excel: str
def _find_target_towe_index(self, tower_name_list: List[str]): def _find_target_tower_index(self, start_tower_name: str, tower_dict):
index = [] index = []
for foo in self._draw_tower_name: tower_key_list = list(tower_dict.keys())
index.append(tower_name_list.index(foo)) 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
continue
if can_start_find and tower_info.is_tension_tower == True:
found_tower_name = tower_info.tower_name
index.append(tower_key_list.index(found_tower_name))
break
return index return index
def _plot(self, cad,plot_x,plot_y):
plot_vector = np2d_to_array(np.hstack((plot_x, plot_y)))
added_curve = cad.model.AddPolyLine(plot_vector)
set_true_color(added_curve, *ColorEnume.wire_color_rgb)
plot_ground_y = plot_y - 18 * 2
plot_ground_vector = np2d_to_array(np.hstack((plot_x, plot_ground_y)))
added_ground_curve = cad.model.AddPolyLine(plot_ground_vector)
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
plot_tree_y = plot_y - 13.5 * 2
plot_tree_vector = np2d_to_array(np.hstack((plot_x, plot_tree_y)))
added_tree_curve = cad.model.AddPolyLine(plot_tree_vector)
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
def draw(self): def draw(self):
# 计算代表档距 # 计算代表档距
s_file = SFile() s_file = SFile()
s_file.open(self._s_file_path) s_file.open(self._s_file_path)
tower_dict = s_file.tower_dic tower_dict = s_file.tower_dic
tower_key_list = list(tower_dict.keys()) tower_key_list = list(tower_dict.keys())
draw_tower_index = self._find_target_towe_index(tower_key_list) draw_tower_index = self._find_target_tower_index(
self._draw_start_tower_name, tower_dict
)
fitting_file_path = deduce_fit_db_from_cad_path(self._dwg_file_path) fitting_file_path = deduce_fit_db_from_cad_path(self._dwg_file_path)
fitting = Fitting(fitting_file_path) fitting = Fitting(fitting_file_path)
z_file_path = deduce_zfile_from_cad_path(self._dwg_file_path) z_file_path = deduce_zfile_from_cad_path(self._dwg_file_path)
@ -107,55 +135,90 @@ class StringImpactPlate:
stringImpactExcel = StringImpactExcel() stringImpactExcel = StringImpactExcel()
cad.app.Documents.Open(self._dwg_file_path) cad.app.Documents.Open(self._dwg_file_path)
sleep(1) sleep(1)
for draw_tower_foo in draw_tower_index: draw_first_tower_key = tower_key_list[draw_tower_index[0]]
draw_tower_key = tower_key_list[draw_tower_foo] first_tower_info = tower_dict[draw_first_tower_key]
tower_info = tower_dict[draw_tower_key] forth_reprtv_span = first_tower_info.forth_representive_span
forth_reprtv_span = tower_info.forth_representive_span 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 forth_tower_info = tower_dict[tower_key_list[draw_tower_index[0] + 1]]
forth_tower_info = tower_dict[tower_key_list[draw_tower_foo + 1]] gaocha_of_first_tower = (
gaocha = ( (
( forth_tower_info.tower_height
forth_tower_info.tower_height - forth_tower_info.foundation_low
- forth_tower_info.foundation_low - fitting.fitting_length_dic[forth_tower_info.fitting]
- fitting.fitting_length_dic[forth_tower_info.fitting]
)
- (
tower_info.tower_height
- tower_info.foundation_low
- fitting.fitting_length_dic[tower_info.fitting]
)
+ forth_tower_info.altitude_off
) )
span = forth_tower_info.mileage_in_s - tower_info.mileage_in_s - (
(x, y) = stringImpactExcel.read( first_tower_info.tower_height
wb_string_impact, gaocha, span, high_temperature_tension - first_tower_info.foundation_low
) )
# TODO: 计算累计里程和高差 + forth_tower_info.altitude_off
plot_x = (plate_origin[0] + x / 5).reshape(len(x), 1) )
plot_y = (plate_origin[1] + (tower_info.tower_height-tower_info.foundation_low+ y)*2 ).reshape(len(x), 1) span_of_first_tower = (
plot_vector = np2d_to_array(np.hstack((plot_x, plot_y))) forth_tower_info.mileage_in_s - first_tower_info.mileage_in_s
added_curve=cad.model.AddPolyLine(plot_vector) )
set_true_color(added_curve,*ColorEnume.wire_color_rgb) (x, y) = stringImpactExcel.read(
plot_ground_y=plot_y-18*2 wb_string_impact,
plot_ground_vector=np2d_to_array(np.hstack((plot_x, plot_ground_y))) gaocha_of_first_tower,
added_ground_curve = cad.model.AddPolyLine(plot_ground_vector) span_of_first_tower,
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb) high_temperature_tension,
plot_tree_y = plot_y - 13.5 * 2 )
plot_tree_vector = np2d_to_array(np.hstack((plot_x, plot_tree_y))) # TODO: 没有考虑断面中间有耐张塔的情况
added_tree_curve = cad.model.AddPolyLine(plot_tree_vector) plot_x = (plate_origin[0] + x / 5).reshape(len(x), 1)
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb) plot_y = (
pass plate_origin[1]
+ (first_tower_info.tower_height - first_tower_info.foundation_low + y)
# can_start=False * 2
# tower_dict_iterator=iter(list(tower_dict.keys())) ).reshape(len(x), 1)
# for tower_info_key in tower_dict_iterator: self._plot(cad,plot_x,plot_y)
# tower_info=tower_dict[tower_info_key] # 画右侧耐张塔的弧垂
# if tower_info.tower_name==self._draw_tower_name: draw_last_tower_key = tower_key_list[draw_tower_index[-1]]
# if tower_info.is_tension_tower==False: last_tower_info = tower_dict[draw_last_tower_key]
# raise Exception('耐张段影响弧垂第1基塔不是耐张塔') back_reprtv_span = last_tower_info.back_representive_span
# can_start=True back_tower_info = tower_dict[tower_key_list[draw_tower_index[-1] - 1]]
# if can_start: gaocha_of_last_tower = (
(
back_tower_info.tower_height
- back_tower_info.foundation_low
- fitting.fitting_length_dic[back_tower_info.fitting]
)
- (
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
)
/ 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)
@define @define
@ -169,16 +232,7 @@ class ContinuousPlate:
s_file = SFile() s_file = SFile()
s_file_path = self._s_file_path s_file_path = self._s_file_path
s_file.open(s_file_path) s_file.open(s_file_path)
# with xw.App(visible=False) as app:
# wb_string_impact = app.books.open("特高压耐张串影响弧垂计算送电室2018人员版1122-1218.xls")
# stringImpactExcel = StringImpactExcel()
# stringImpactExcel.read(wb_string_impact)
dwg_file_path = self._dwg_file_path dwg_file_path = self._dwg_file_path
# with xw.App(visible=False) as app:
# wb = app.books.open('张力计算(临界档距公式法V20090602)-送电室版).xls')
# sheet = wb.sheets['2710导线-单回1250-70']
# sheet.range('B69').value=120
# print(sheet.range('L69').value)
with Apyautocad( with Apyautocad(
create_if_not_exists=True, visible=False, auto_close=False create_if_not_exists=True, visible=False, auto_close=False
) as cad: ) as cad:
@ -468,7 +522,7 @@ def main():
string_impact_plate = StringImpactPlate( string_impact_plate = StringImpactPlate(
r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg", r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg",
r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\S033.DAT", r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\S033.DAT",
["N3339"], "N3339",
"", "",
"", "",
) )