Compare commits
4 Commits
ce1ff065d1
...
eabb62f8f5
| Author | SHA1 | Date |
|---|---|---|
|
|
eabb62f8f5 | |
|
|
475ce6c367 | |
|
|
034ba492c7 | |
|
|
2109957df1 |
|
|
@ -0,0 +1,2 @@
|
||||||
|
generate_ui:
|
||||||
|
pyuic6 ui/mainwindow.ui -o ui/mainwindow.py
|
||||||
327
PWFile.py
327
PWFile.py
|
|
@ -12,6 +12,17 @@ from time import sleep
|
||||||
from attrs import define
|
from attrs import define
|
||||||
from typing import List
|
from typing import List
|
||||||
import error
|
import error
|
||||||
|
from array import array
|
||||||
|
|
||||||
|
|
||||||
|
def get_layer_if_not_exist_create_it(doc, layer_name):
|
||||||
|
layers = doc.Layers
|
||||||
|
for foo in range(layers.Count):
|
||||||
|
layer = layers.Item(foo)
|
||||||
|
if layer.Name == layer_name:
|
||||||
|
return layer
|
||||||
|
return layers.Add(layer_name)
|
||||||
|
|
||||||
|
|
||||||
@define
|
@define
|
||||||
class SEntry:
|
class SEntry:
|
||||||
|
|
@ -195,49 +206,88 @@ class StringImpactPlate:
|
||||||
_dwg_file_path: str
|
_dwg_file_path: str
|
||||||
_s_file_path: str
|
_s_file_path: str
|
||||||
_draw_start_tower_name: str
|
_draw_start_tower_name: str
|
||||||
|
_draw_end_tower_name: str
|
||||||
_continouse_tension_excel: str
|
_continouse_tension_excel: str
|
||||||
_string_impact_curve_excel: str
|
_string_impact_curve_excel: str
|
||||||
_cad: None
|
_cad: None
|
||||||
excel_record_list: List = [] # 记录对excel的操作
|
excel_record_list: List = [] # 记录对excel的操作
|
||||||
|
|
||||||
def _find_target_tower_index(self, start_tower_name: str, tower_dict):
|
def _find_target_tower_index(
|
||||||
|
self, start_tower_name: str, end_tower_name, tower_dict
|
||||||
|
):
|
||||||
# 从 start_tower_name开始,寻找一个耐张段
|
# 从 start_tower_name开始,寻找一个耐张段
|
||||||
index = []
|
index = []
|
||||||
tower_key_list = list(tower_dict.keys())
|
tower_key_list = list(tower_dict.keys())
|
||||||
index.append(tower_key_list.index(start_tower_name))
|
try:
|
||||||
can_start_find = False
|
index_of_first_tower = tower_key_list.index(start_tower_name)
|
||||||
for tower_key in tower_key_list:
|
if (
|
||||||
tower_info = tower_dict[tower_key]
|
tower_dict[tower_key_list[index_of_first_tower]].is_tension_tower
|
||||||
if tower_info.tower_name == start_tower_name:
|
== True
|
||||||
can_start_find = True
|
):
|
||||||
continue
|
index.append(index_of_first_tower)
|
||||||
if can_start_find and tower_info.is_tension_tower == True:
|
except ValueError: # 没找到第一个塔,就直接返回
|
||||||
found_tower_name = tower_info.tower_name
|
return index
|
||||||
index.append(tower_key_list.index(found_tower_name))
|
try:
|
||||||
|
index_of_last_tower = tower_key_list.index(end_tower_name)
|
||||||
|
# 开始补充第一个和最后一个直接的耐张塔
|
||||||
|
for index_of_tension_tower in range(
|
||||||
|
index_of_first_tower + 1, index_of_last_tower
|
||||||
|
):
|
||||||
|
if (
|
||||||
|
tower_dict[tower_key_list[index_of_tension_tower]].is_tension_tower
|
||||||
|
== True
|
||||||
|
):
|
||||||
|
index.append(index_of_tension_tower)
|
||||||
|
if tower_dict[tower_key_list[index_of_last_tower]].is_tension_tower == True:
|
||||||
|
index.append(index_of_last_tower)
|
||||||
|
except ValueError: # 没找到最后一个塔,就只画一个耐张段
|
||||||
|
for index_of_tension_tower in range(
|
||||||
|
index_of_first_tower + 1, len(tower_key_list)
|
||||||
|
):
|
||||||
|
if (
|
||||||
|
tower_dict[tower_key_list[index_of_tension_tower]].is_tension_tower
|
||||||
|
== True
|
||||||
|
):
|
||||||
|
index.append(index_of_tension_tower)
|
||||||
break
|
break
|
||||||
|
# can_start_find = False
|
||||||
|
# for tower_key in tower_key_list:
|
||||||
|
# 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):
|
def _plot(self, cad, plot_x, plot_y):
|
||||||
|
custom_layer = get_layer_if_not_exist_create_it(cad.doc, "123custom_layer")
|
||||||
plot_vector = np2d_to_array(np.hstack((plot_x, plot_y)))
|
plot_vector = np2d_to_array(np.hstack((plot_x, plot_y)))
|
||||||
added_curve = cad.model.AddPolyLine(plot_vector)
|
added_curve = cad.model.AddPolyLine(plot_vector)
|
||||||
|
added_curve.Layer = custom_layer.Name
|
||||||
set_true_color(added_curve, *ColorEnume.wire_color_rgb)
|
set_true_color(added_curve, *ColorEnume.wire_color_rgb)
|
||||||
plot_ground_y = plot_y - 18 * 2
|
# TODO 应该读规程的
|
||||||
|
plot_ground_y = plot_y - 16 * 2
|
||||||
plot_ground_vector = np2d_to_array(np.hstack((plot_x, plot_ground_y)))
|
plot_ground_vector = np2d_to_array(np.hstack((plot_x, plot_ground_y)))
|
||||||
added_ground_curve = cad.model.AddPolyLine(plot_ground_vector)
|
added_ground_curve = cad.model.AddPolyLine(plot_ground_vector)
|
||||||
|
added_ground_curve.Layer = custom_layer.Name
|
||||||
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
|
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
|
||||||
plot_tree_y = plot_y - 13.5 * 2
|
plot_tree_y = plot_y - 13.5 * 2
|
||||||
plot_tree_vector = np2d_to_array(np.hstack((plot_x, plot_tree_y)))
|
plot_tree_vector = np2d_to_array(np.hstack((plot_x, plot_tree_y)))
|
||||||
added_tree_curve = cad.model.AddPolyLine(plot_tree_vector)
|
added_tree_curve = cad.model.AddPolyLine(plot_tree_vector)
|
||||||
|
added_tree_curve.Layer = custom_layer.Name
|
||||||
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
||||||
|
|
||||||
def _draw_action(self, excel_app, cad):
|
def _draw_action(self, excel_app, cad):
|
||||||
# 计算代表档距
|
# TODO 计算代表档距
|
||||||
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_tower_index(
|
draw_tower_indexes = self._find_target_tower_index(
|
||||||
self._draw_start_tower_name, tower_dict
|
self._draw_start_tower_name, self._draw_end_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)
|
||||||
|
|
@ -248,14 +298,18 @@ class StringImpactPlate:
|
||||||
wb_string_impact = excel_app.books.open(self._string_impact_curve_excel)
|
wb_string_impact = excel_app.books.open(self._string_impact_curve_excel)
|
||||||
stringImpactExcel = StringImpactExcel()
|
stringImpactExcel = StringImpactExcel()
|
||||||
sleep(1)
|
sleep(1)
|
||||||
draw_first_tower_key = tower_key_list[draw_tower_index[0]]
|
for draw_tower_index in draw_tower_indexes:
|
||||||
first_tower_info: SEntry = tower_dict[draw_first_tower_key]
|
draw_tower_key = tower_key_list[draw_tower_index]
|
||||||
forth_reprtv_span = first_tower_info.forth_representive_span
|
tower_info: SEntry = tower_dict[draw_tower_key]
|
||||||
|
if draw_tower_index < tower_key_list.index(
|
||||||
|
self._draw_end_tower_name
|
||||||
|
): # 不是最后一个,或者只有第一个。
|
||||||
|
# 画前侧
|
||||||
|
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
|
||||||
if first_tower_info.is_tension_tower:
|
|
||||||
forth_tower_info: SEntry = tower_dict[
|
forth_tower_info: SEntry = tower_dict[
|
||||||
tower_key_list[draw_tower_index[0] + 1]
|
tower_key_list[draw_tower_index + 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
|
||||||
|
|
@ -263,48 +317,54 @@ class StringImpactPlate:
|
||||||
forth_tower_fitting_length = fitting.fitting_length_dic[
|
forth_tower_fitting_length = fitting.fitting_length_dic[
|
||||||
forth_tower_info.fitting
|
forth_tower_info.fitting
|
||||||
]
|
]
|
||||||
gaocha_of_first_tower = (
|
gaocha_of_tower = (
|
||||||
(
|
(
|
||||||
forth_tower_info.tower_height
|
forth_tower_info.tower_height
|
||||||
- forth_tower_info.foundation_low
|
- forth_tower_info.foundation_low
|
||||||
- forth_tower_fitting_length
|
- forth_tower_fitting_length
|
||||||
)
|
)
|
||||||
- (first_tower_info.tower_height - first_tower_info.foundation_low)
|
- (tower_info.tower_height - tower_info.foundation_low)
|
||||||
+ forth_tower_info.altitude_off
|
+ forth_tower_info.altitude_off
|
||||||
)
|
)
|
||||||
span_of_first_tower = (
|
span_of_tower = forth_tower_info.mileage_in_s - tower_info.mileage_in_s
|
||||||
forth_tower_info.mileage_in_s - first_tower_info.mileage_in_s
|
|
||||||
)
|
|
||||||
(x, y) = stringImpactExcel.read(
|
(x, y) = stringImpactExcel.read(
|
||||||
wb_string_impact,
|
wb_string_impact,
|
||||||
gaocha_of_first_tower,
|
gaocha_of_tower,
|
||||||
span_of_first_tower,
|
span_of_tower,
|
||||||
high_temperature_tension,
|
high_temperature_tension,
|
||||||
)
|
)
|
||||||
# TODO: 没有考虑断面中间有耐张塔的情况
|
plot_x = (
|
||||||
plot_x = (plate_origin[0] + x / 5).reshape(len(x), 1)
|
plate_origin[0]
|
||||||
|
+ (
|
||||||
|
tower_dict[tower_key_list[draw_tower_index]].mileage_in_s
|
||||||
|
- tower_dict[self._draw_start_tower_name].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(
|
||||||
|
tower_key_list.index(self._draw_start_tower_name) + 1, draw_tower_index + 1
|
||||||
|
)
|
||||||
|
]
|
||||||
|
)
|
||||||
plot_y = (
|
plot_y = (
|
||||||
plate_origin[1]
|
plate_origin[1]
|
||||||
+ (first_tower_info.tower_height - first_tower_info.foundation_low + y)
|
+ accumulate_altitude_off * 2
|
||||||
* 2
|
+ (tower_info.tower_height - 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)
|
||||||
# 记录
|
if draw_tower_index > tower_key_list.index(
|
||||||
record = StringImpactExcelRecord()
|
self._draw_start_tower_name
|
||||||
record.from_tower_name = first_tower_info.tower_name
|
): # 不是第一个,或者只有最后一个
|
||||||
record.fo_tower_name = forth_tower_info.tower_name
|
# 画后侧
|
||||||
record.span = span_of_first_tower
|
back_reprtv_span = tower_info.back_representive_span
|
||||||
record.representive_span = first_tower_info.forth_representive_span
|
continouse_sheet.range("B69").value = back_reprtv_span
|
||||||
record.gaocha = gaocha_of_first_tower
|
high_temperature_tension = continouse_sheet.range("L69").value
|
||||||
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: 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[
|
back_tower_info: SEntry = tower_dict[
|
||||||
tower_key_list[draw_tower_index[-1] - 1]
|
tower_key_list[draw_tower_index - 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
|
||||||
|
|
@ -312,29 +372,27 @@ class StringImpactPlate:
|
||||||
back_tower_fitting_length = fitting.fitting_length_dic[
|
back_tower_fitting_length = fitting.fitting_length_dic[
|
||||||
back_tower_info.fitting
|
back_tower_info.fitting
|
||||||
]
|
]
|
||||||
gaocha_of_last_tower = (
|
gaocha_of_tower = (
|
||||||
(
|
(
|
||||||
back_tower_info.tower_height
|
back_tower_info.tower_height
|
||||||
- back_tower_info.foundation_low
|
- back_tower_info.foundation_low
|
||||||
- back_tower_fitting_length
|
- back_tower_fitting_length
|
||||||
)
|
)
|
||||||
- (last_tower_info.tower_height - last_tower_info.foundation_low)
|
- (tower_info.tower_height - tower_info.foundation_low)
|
||||||
- last_tower_info.altitude_off
|
- tower_info.altitude_off
|
||||||
)
|
|
||||||
span_of_last_tower = (
|
|
||||||
last_tower_info.mileage_in_s - back_tower_info.mileage_in_s
|
|
||||||
)
|
)
|
||||||
|
span_of_tower = 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_tower,
|
||||||
span_of_last_tower,
|
span_of_tower,
|
||||||
high_temperature_tension,
|
high_temperature_tension,
|
||||||
)
|
)
|
||||||
plot_last_tower_x = (
|
plot_tower_x = (
|
||||||
plate_origin[0]
|
plate_origin[0]
|
||||||
+ (
|
+ (
|
||||||
tower_dict[tower_key_list[draw_tower_index[-1]]].mileage_in_s
|
tower_dict[tower_key_list[draw_tower_index]].mileage_in_s
|
||||||
- tower_dict[tower_key_list[draw_tower_index[0]]].mileage_in_s
|
- tower_dict[self._draw_start_tower_name].mileage_in_s
|
||||||
)
|
)
|
||||||
/ 5
|
/ 5
|
||||||
- x / 5 # 从右往左画
|
- x / 5 # 从右往左画
|
||||||
|
|
@ -342,19 +400,125 @@ class StringImpactPlate:
|
||||||
accumulate_altitude_off = np.sum(
|
accumulate_altitude_off = np.sum(
|
||||||
[
|
[
|
||||||
tower_dict[tower_key_list[bar]].altitude_off
|
tower_dict[tower_key_list[bar]].altitude_off
|
||||||
for bar in range(draw_tower_index[0] + 1, draw_tower_index[-1] + 1)
|
for bar in range(
|
||||||
|
tower_key_list.index(self._draw_start_tower_name) + 1, draw_tower_index + 1
|
||||||
|
)
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
plot_last_tower_y = (
|
plot_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)
|
+ (tower_info.tower_height - tower_info.foundation_low + y) * 2
|
||||||
* 2
|
|
||||||
).reshape(len(x), 1)
|
).reshape(len(x), 1)
|
||||||
plot_last_tower_vector = np2d_to_array(
|
self._plot(cad, plot_tower_x, plot_tower_y)
|
||||||
np.hstack((plot_last_tower_x, plot_last_tower_y))
|
# draw_first_tower_key = tower_key_list[draw_tower_indexes[0]]
|
||||||
)
|
# first_tower_info: SEntry = tower_dict[draw_first_tower_key]
|
||||||
self._plot(cad, plot_last_tower_x, plot_last_tower_y)
|
# 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
|
||||||
|
# if first_tower_info.is_tension_tower:
|
||||||
|
# forth_tower_info: SEntry = tower_dict[
|
||||||
|
# tower_key_list[draw_tower_indexes[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
|
||||||
|
# )
|
||||||
|
# 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)
|
||||||
|
# # 记录
|
||||||
|
# # TODO:记录还没有用
|
||||||
|
# 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_indexes[-1]]
|
||||||
|
# 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_indexes[-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
|
||||||
|
# )
|
||||||
|
# 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_indexes[-1]]].mileage_in_s
|
||||||
|
# - tower_dict[tower_key_list[draw_tower_indexes[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_indexes[0] + 1, draw_tower_indexes[-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):
|
def draw(self):
|
||||||
if self._cad:
|
if self._cad:
|
||||||
|
|
@ -390,6 +554,7 @@ class ContinuousPlate:
|
||||||
self.cad = cad
|
self.cad = cad
|
||||||
doc = cad.app.Documents.Open(dwg_file_path)
|
doc = cad.app.Documents.Open(dwg_file_path)
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
custom_layer = get_layer_if_not_exist_create_it(doc, "123custom_layer")
|
||||||
tower_dict = s_file.tower_dic
|
tower_dict = s_file.tower_dic
|
||||||
z_file_path = deduce_zfile_from_cad_path(dwg_file_path)
|
z_file_path = deduce_zfile_from_cad_path(dwg_file_path)
|
||||||
z_point = plane_z_origin(z_file_path)
|
z_point = plane_z_origin(z_file_path)
|
||||||
|
|
@ -441,6 +606,7 @@ class ContinuousPlate:
|
||||||
added_represented_span_text,
|
added_represented_span_text,
|
||||||
ColorEnume.representive_span_text_color_rgb,
|
ColorEnume.representive_span_text_color_rgb,
|
||||||
)
|
)
|
||||||
|
added_represented_span_text.Layer = custom_layer.Name
|
||||||
if is_first_tower: # 是否是开始画的第一个塔。
|
if is_first_tower: # 是否是开始画的第一个塔。
|
||||||
accu_altitude_off = 0
|
accu_altitude_off = 0
|
||||||
else:
|
else:
|
||||||
|
|
@ -479,14 +645,16 @@ class ContinuousPlate:
|
||||||
tower_pole = cad.model.AddPolyLine(
|
tower_pole = cad.model.AddPolyLine(
|
||||||
np2d_to_array(np.vstack((np_tower_start, np_tower_end)))
|
np2d_to_array(np.vstack((np_tower_start, np_tower_end)))
|
||||||
)
|
)
|
||||||
|
tower_pole.Layer = custom_layer.Name
|
||||||
tower_pole.SetWidth(0, 0.8, 0.8)
|
tower_pole.SetWidth(0, 0.8, 0.8)
|
||||||
set_true_color(tower_pole, 0, 255, 255)
|
set_true_color(tower_pole, 0, 255, 255)
|
||||||
# 画塔名和呼高
|
# 画塔名和呼高
|
||||||
cad.model.AddText(
|
added_tower_name = 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,
|
||||||
)
|
)
|
||||||
|
added_tower_name.Layer = custom_layer.Name
|
||||||
if (
|
if (
|
||||||
abs(math.floor(tower_info.tower_height) - tower_info.tower_height)
|
abs(math.floor(tower_info.tower_height) - tower_info.tower_height)
|
||||||
< 0.1
|
< 0.1
|
||||||
|
|
@ -494,11 +662,12 @@ class ContinuousPlate:
|
||||||
draw_tower_height_str = f"{tower_info.tower_height:.0f}"
|
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(
|
added_hugao = 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()),
|
||||||
5,
|
5,
|
||||||
)
|
)
|
||||||
|
added_hugao.Layer = custom_layer.Name
|
||||||
draw_count += 1
|
draw_count += 1
|
||||||
# 画弧垂
|
# 画弧垂
|
||||||
if not is_first_tower: # 从第二基塔开始画
|
if not is_first_tower: # 从第二基塔开始画
|
||||||
|
|
@ -544,7 +713,8 @@ class ContinuousPlate:
|
||||||
)
|
)
|
||||||
draw_curve_x = draw_curve_x.reshape(len(draw_curve_x), 1)
|
draw_curve_x = draw_curve_x.reshape(len(draw_curve_x), 1)
|
||||||
draw_curve_y = draw_curve_y.reshape(len(draw_curve_y), 1)
|
draw_curve_y = draw_curve_y.reshape(len(draw_curve_y), 1)
|
||||||
draw_ground_curve_y = draw_curve_y - 18 * 2 # 切地线
|
# TODO 应该读规程的
|
||||||
|
draw_ground_curve_y = draw_curve_y - 16 * 2 # 切地线
|
||||||
draw_tree_curve_y = draw_curve_y - 13.5 * 2 # 切树线
|
draw_tree_curve_y = draw_curve_y - 13.5 * 2 # 切树线
|
||||||
draw_point = np.hstack(
|
draw_point = np.hstack(
|
||||||
(draw_curve_x, draw_curve_y, np.zeros((len(draw_curve_x), 1)))
|
(draw_curve_x, draw_curve_y, np.zeros((len(draw_curve_x), 1)))
|
||||||
|
|
@ -566,18 +736,21 @@ class ContinuousPlate:
|
||||||
added_curve = cad.model.AddPolyLine(
|
added_curve = cad.model.AddPolyLine(
|
||||||
draw_point.reshape(1, draw_curve_x.shape[0] * 3)[0]
|
draw_point.reshape(1, draw_curve_x.shape[0] * 3)[0]
|
||||||
)
|
)
|
||||||
|
added_curve.Layer = custom_layer.Name
|
||||||
set_true_color(added_curve, *ColorEnume.wire_color_rgb)
|
set_true_color(added_curve, *ColorEnume.wire_color_rgb)
|
||||||
added_ground_curve = cad.model.AddPolyLine(
|
added_ground_curve = cad.model.AddPolyLine(
|
||||||
draw_ground_curve_point.reshape(
|
draw_ground_curve_point.reshape(
|
||||||
1, draw_ground_curve_y.shape[0] * 3
|
1, draw_ground_curve_y.shape[0] * 3
|
||||||
)[0]
|
)[0]
|
||||||
)
|
)
|
||||||
|
added_ground_curve.Layer = custom_layer.Name
|
||||||
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
|
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
|
||||||
added_tree_curve = cad.model.AddPolyLine(
|
added_tree_curve = cad.model.AddPolyLine(
|
||||||
draw_tree_curve_point.reshape(
|
draw_tree_curve_point.reshape(
|
||||||
1, draw_tree_curve_y.shape[0] * 3
|
1, draw_tree_curve_y.shape[0] * 3
|
||||||
)[0]
|
)[0]
|
||||||
)
|
)
|
||||||
|
added_tree_curve.Layer = custom_layer.Name
|
||||||
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
||||||
# 画档距
|
# 画档距
|
||||||
span_text_insert_point = np.array(
|
span_text_insert_point = np.array(
|
||||||
|
|
@ -586,7 +759,23 @@ class ContinuousPlate:
|
||||||
added_span_text = cad.model.AddText(
|
added_span_text = cad.model.AddText(
|
||||||
f"{span:.0f}", APoint(*span_text_insert_point.tolist()), 3
|
f"{span:.0f}", APoint(*span_text_insert_point.tolist()), 3
|
||||||
)
|
)
|
||||||
|
# 画档距分割线
|
||||||
|
add_span_splitter = cad.model.AddPolyLine(
|
||||||
|
array(
|
||||||
|
"d",
|
||||||
|
[
|
||||||
|
(accu_mileage) / 5 + 50,
|
||||||
|
5,
|
||||||
|
0,
|
||||||
|
(accu_mileage) / 5 + 50,
|
||||||
|
10,
|
||||||
|
0,
|
||||||
|
],
|
||||||
|
)
|
||||||
|
)
|
||||||
|
add_span_splitter.Layer = custom_layer.Name
|
||||||
set_true_color(added_span_text, *ColorEnume.span_text_color_rgb)
|
set_true_color(added_span_text, *ColorEnume.span_text_color_rgb)
|
||||||
|
added_span_text.Layer = custom_layer.Name
|
||||||
is_first_tower = False
|
is_first_tower = False
|
||||||
last_tower_info = tower_info
|
last_tower_info = tower_info
|
||||||
|
|
||||||
|
|
@ -646,6 +835,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._end_tower_name,
|
||||||
self._excel_continuous_path,
|
self._excel_continuous_path,
|
||||||
self._excel_string_weight_path,
|
self._excel_string_weight_path,
|
||||||
continuous_plate.cad,
|
continuous_plate.cad,
|
||||||
|
|
@ -653,6 +843,7 @@ class ControlFile:
|
||||||
string_impact_plate.draw()
|
string_impact_plate.draw()
|
||||||
cad = continuous_plate.cad
|
cad = continuous_plate.cad
|
||||||
cad.doc.SaveAs(self.get_zt_dwg_file_path())
|
cad.doc.SaveAs(self.get_zt_dwg_file_path())
|
||||||
|
cad.doc.Utility.Prompt("断面已生成。\n")
|
||||||
# # 画完后再打开
|
# # 画完后再打开
|
||||||
# cad = None
|
# cad = None
|
||||||
# continousePlate = None
|
# continousePlate = None
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,54 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<ui version="4.0">
|
||||||
|
<class>mainWindow</class>
|
||||||
|
<widget class="QDialog" name="mainWindow">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
<width>400</width>
|
||||||
|
<height>300</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="windowTitle">
|
||||||
|
<string>生成断面</string>
|
||||||
|
</property>
|
||||||
|
<widget class="QPushButton" name="pBOpenControlZFile">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>120</x>
|
||||||
|
<y>100</y>
|
||||||
|
<width>131</width>
|
||||||
|
<height>71</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>打开Z控制文件</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
<widget class="QCheckBox" name="cBCloseCadDoc">
|
||||||
|
<property name="geometry">
|
||||||
|
<rect>
|
||||||
|
<x>40</x>
|
||||||
|
<y>40</y>
|
||||||
|
<width>211</width>
|
||||||
|
<height>21</height>
|
||||||
|
</rect>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<family>AcadEref</family>
|
||||||
|
<pointsize>10</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>生成断面图后自动关闭CAD文档</string>
|
||||||
|
</property>
|
||||||
|
<property name="checked">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</widget>
|
||||||
|
<resources/>
|
||||||
|
<connections/>
|
||||||
|
</ui>
|
||||||
Loading…
Reference in New Issue