2022-07-24 16:47:21 +08:00
|
|
|
|
from tkinter.messagebox import NO
|
|
|
|
|
|
import xlwings as xw
|
2022-07-25 03:47:28 +08:00
|
|
|
|
from PWFile import SFile, Fitting, ColorEnume
|
2022-07-24 16:47:21 +08:00
|
|
|
|
from Apyautocad import Apyautocad, APoint
|
|
|
|
|
|
import os
|
|
|
|
|
|
import re
|
|
|
|
|
|
import numpy as np
|
|
|
|
|
|
from time import sleep
|
2022-07-24 17:18:57 +08:00
|
|
|
|
from attrs import define
|
2022-07-25 02:05:08 +08:00
|
|
|
|
from typing import List
|
2022-07-24 16:47:21 +08:00
|
|
|
|
|
|
|
|
|
|
# 读取Z文件,找到Z断面第一个点的坐标
|
|
|
|
|
|
def plane_z_origin(z_file_path):
|
|
|
|
|
|
with open(z_file_path) as zfile:
|
|
|
|
|
|
content = zfile.read()
|
|
|
|
|
|
norm_content = re.sub("\s+", ",", content)
|
|
|
|
|
|
sep = norm_content.split(",")
|
|
|
|
|
|
return np.array([float(sep[0]), float(sep[1])])
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deduce_zfile_from_cad_path(cad_file_path):
|
|
|
|
|
|
dwg_file_name = os.path.split(cad_file_path)
|
|
|
|
|
|
dwg_prefix = dwg_file_name[1].split(".")[0]
|
|
|
|
|
|
return os.path.join(dwg_file_name[0], f"Z{dwg_prefix}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def deduce_fit_db_from_cad_path(cad_file_path):
|
|
|
|
|
|
dwg_file_name = os.path.split(cad_file_path)
|
|
|
|
|
|
dwg_prefix = dwg_file_name[1].split(".")[0]
|
|
|
|
|
|
return os.path.join(dwg_file_name[0], "Fit.db")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def curve_fun(x, span, k, gaocha):
|
|
|
|
|
|
return x * gaocha / span - x * (span - x) * k
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-25 02:05:08 +08:00
|
|
|
|
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]
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-24 16:47:21 +08:00
|
|
|
|
class StringImpactExcel:
|
|
|
|
|
|
def __init__(self) -> None:
|
|
|
|
|
|
# self._wb=None
|
|
|
|
|
|
pass
|
|
|
|
|
|
|
2022-07-25 02:05:08 +08:00
|
|
|
|
def read(self, wb, gaocha, span, tension):
|
2022-07-24 16:47:21 +08:00
|
|
|
|
pos代表档距 = "F13"
|
|
|
|
|
|
pos档距 = "L13"
|
|
|
|
|
|
pos高差 = "R13"
|
|
|
|
|
|
pos张力 = "AB18"
|
2022-07-25 02:05:08 +08:00
|
|
|
|
pos总串长 = "C8"
|
2022-07-24 16:47:21 +08:00
|
|
|
|
sheet = wb.sheets["3225-3226"]
|
2022-07-25 02:05:08 +08:00
|
|
|
|
sheet.range(pos高差).value = gaocha
|
|
|
|
|
|
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
|
2022-07-25 03:47:28 +08:00
|
|
|
|
x[1] = sheet.range("E24").value
|
2022-07-25 02:05:08 +08:00
|
|
|
|
sheet.range(f"E25:E{25+len(x)-3}").value = x[2:].reshape(len(x[2:]), 1)
|
2022-07-25 03:47:28 +08:00
|
|
|
|
y = (
|
|
|
|
|
|
np.array(sheet.range(f"V23:V{23+len(x)-1}").value) / 2
|
|
|
|
|
|
) # 表格是乘以了2的,为了和x保持一致,没有乘比例。
|
2022-07-25 02:05:08 +08:00
|
|
|
|
return (x, y)
|
2022-07-24 16:47:21 +08:00
|
|
|
|
|
|
|
|
|
|
|
2022-07-24 17:18:57 +08:00
|
|
|
|
def set_true_color(object, r, g, b):
|
|
|
|
|
|
true_color = object.TrueColor
|
|
|
|
|
|
true_color.SetRGB(r, g, b)
|
|
|
|
|
|
object.TrueColor = true_color
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-25 02:05:08 +08:00
|
|
|
|
@define
|
|
|
|
|
|
class StringImpactPlate:
|
|
|
|
|
|
_dwg_file_path: str
|
|
|
|
|
|
_s_file_path: str
|
2022-07-25 03:47:28 +08:00
|
|
|
|
_draw_start_tower_name: str
|
2022-07-25 02:05:08 +08:00
|
|
|
|
# _tension_section:int#耐张段数量
|
|
|
|
|
|
_continouse_tension_excel: str
|
|
|
|
|
|
_string_impact_curve_excel: str
|
|
|
|
|
|
|
2022-07-25 03:47:28 +08:00
|
|
|
|
def _find_target_tower_index(self, start_tower_name: str, tower_dict):
|
2022-07-25 02:05:08 +08:00
|
|
|
|
index = []
|
2022-07-25 03:47:28 +08:00
|
|
|
|
tower_key_list = list(tower_dict.keys())
|
|
|
|
|
|
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
|
2022-07-25 02:05:08 +08:00
|
|
|
|
return index
|
|
|
|
|
|
|
2022-07-25 03:47:28 +08:00
|
|
|
|
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)
|
|
|
|
|
|
|
2022-07-25 02:05:08 +08:00
|
|
|
|
def draw(self):
|
|
|
|
|
|
# 计算代表档距
|
|
|
|
|
|
s_file = SFile()
|
|
|
|
|
|
s_file.open(self._s_file_path)
|
|
|
|
|
|
tower_dict = s_file.tower_dic
|
|
|
|
|
|
tower_key_list = list(tower_dict.keys())
|
2022-07-25 03:47:28 +08:00
|
|
|
|
draw_tower_index = self._find_target_tower_index(
|
|
|
|
|
|
self._draw_start_tower_name, tower_dict
|
|
|
|
|
|
)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
fitting_file_path = deduce_fit_db_from_cad_path(self._dwg_file_path)
|
|
|
|
|
|
fitting = Fitting(fitting_file_path)
|
|
|
|
|
|
z_file_path = deduce_zfile_from_cad_path(self._dwg_file_path)
|
|
|
|
|
|
plate_origin = plane_z_origin(z_file_path)
|
|
|
|
|
|
with xw.App(visible=True) as excel_app, Apyautocad(
|
|
|
|
|
|
create_if_not_exists=True, visible=True, auto_close=False
|
|
|
|
|
|
) as cad:
|
|
|
|
|
|
continouse_wb = excel_app.books.open("张力计算(临界档距公式法V20090602)-送电室版).xls")
|
|
|
|
|
|
continouse_sheet = continouse_wb.sheets["2710导线-单回1250-70"]
|
|
|
|
|
|
wb_string_impact = excel_app.books.open(
|
|
|
|
|
|
"特高压耐张串影响弧垂计算(送电室2018人员版)1122-1218.xls"
|
|
|
|
|
|
)
|
|
|
|
|
|
stringImpactExcel = StringImpactExcel()
|
|
|
|
|
|
cad.app.Documents.Open(self._dwg_file_path)
|
|
|
|
|
|
sleep(1)
|
2022-07-25 03:47:28 +08:00
|
|
|
|
draw_first_tower_key = tower_key_list[draw_tower_index[0]]
|
|
|
|
|
|
first_tower_info = 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 = tower_dict[tower_key_list[draw_tower_index[0] + 1]]
|
|
|
|
|
|
gaocha_of_first_tower = (
|
|
|
|
|
|
(
|
|
|
|
|
|
forth_tower_info.tower_height
|
|
|
|
|
|
- forth_tower_info.foundation_low
|
|
|
|
|
|
- fitting.fitting_length_dic[forth_tower_info.fitting]
|
2022-07-25 02:05:08 +08:00
|
|
|
|
)
|
2022-07-25 03:47:28 +08:00
|
|
|
|
- (
|
|
|
|
|
|
first_tower_info.tower_height
|
|
|
|
|
|
- first_tower_info.foundation_low
|
2022-07-25 02:05:08 +08:00
|
|
|
|
)
|
2022-07-25 03:47:28 +08:00
|
|
|
|
+ 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)
|
|
|
|
|
|
# 画右侧耐张塔的弧垂
|
|
|
|
|
|
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 = tower_dict[tower_key_list[draw_tower_index[-1] - 1]]
|
|
|
|
|
|
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)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
|
|
|
|
|
|
|
2022-07-24 17:18:57 +08:00
|
|
|
|
@define
|
|
|
|
|
|
class ContinuousPlate:
|
|
|
|
|
|
_dwg_file_path: str
|
|
|
|
|
|
_s_file_path: str
|
|
|
|
|
|
_from_tower_name: str
|
|
|
|
|
|
_draw_tower_count: int
|
|
|
|
|
|
|
|
|
|
|
|
def draw(self, save_to: str):
|
|
|
|
|
|
s_file = SFile()
|
|
|
|
|
|
s_file_path = self._s_file_path
|
|
|
|
|
|
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
|
|
|
|
|
|
) as cad:
|
|
|
|
|
|
doc = cad.app.Documents.Open(dwg_file_path)
|
|
|
|
|
|
sleep(1)
|
|
|
|
|
|
z_file_path = deduce_zfile_from_cad_path(dwg_file_path)
|
|
|
|
|
|
z_point = plane_z_origin(z_file_path)
|
|
|
|
|
|
fitting_file_path = deduce_fit_db_from_cad_path(dwg_file_path)
|
|
|
|
|
|
fitting = Fitting(fitting_file_path)
|
|
|
|
|
|
fitting_length_dict = fitting.fitting_length_dic
|
|
|
|
|
|
first_tower_point = z_point
|
|
|
|
|
|
last_tower_info = None # 上一个塔位信息
|
|
|
|
|
|
accu_mileage = 0 # 累计档距
|
|
|
|
|
|
accu_altitude_off = 0 # 累计高差
|
|
|
|
|
|
is_first_tower = True
|
2022-07-25 02:05:08 +08:00
|
|
|
|
can_start_draw = -1
|
|
|
|
|
|
start_tower_name = self._from_tower_name
|
|
|
|
|
|
draw_count = 0
|
2022-07-24 17:18:57 +08:00
|
|
|
|
for tower in s_file.tower_dic:
|
|
|
|
|
|
tower_info = s_file.tower_dic[tower]
|
2022-07-25 02:05:08 +08:00
|
|
|
|
if tower_info.tower_name == start_tower_name:
|
|
|
|
|
|
can_start_draw = 0
|
|
|
|
|
|
if can_start_draw < 0 or draw_count > self._draw_tower_count - 1:
|
2022-07-24 17:18:57 +08:00
|
|
|
|
break
|
|
|
|
|
|
if not last_tower_info:
|
|
|
|
|
|
last_tower_info = tower_info
|
|
|
|
|
|
foundation_low = tower_info.foundation_low
|
|
|
|
|
|
accu_mileage = (
|
|
|
|
|
|
accu_mileage
|
|
|
|
|
|
+ tower_info.mileage_in_s
|
|
|
|
|
|
- last_tower_info.mileage_in_s
|
|
|
|
|
|
)
|
|
|
|
|
|
accu_altitude_off = accu_altitude_off + tower_info.altitude_off # 中心桩高程
|
|
|
|
|
|
tower_start = APoint(
|
|
|
|
|
|
*(
|
|
|
|
|
|
(
|
|
|
|
|
|
first_tower_point
|
|
|
|
|
|
+ np.array(
|
|
|
|
|
|
[
|
|
|
|
|
|
accu_mileage / 5,
|
|
|
|
|
|
(accu_altitude_off - foundation_low) * 2,
|
|
|
|
|
|
]
|
|
|
|
|
|
)
|
|
|
|
|
|
).tolist()
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
tower_height = tower_info.tower_height
|
|
|
|
|
|
tower_end = APoint(
|
|
|
|
|
|
*(
|
|
|
|
|
|
first_tower_point
|
|
|
|
|
|
+ np.array(
|
|
|
|
|
|
[
|
|
|
|
|
|
accu_mileage / 5,
|
|
|
|
|
|
(accu_altitude_off + tower_height - foundation_low) * 2,
|
|
|
|
|
|
]
|
|
|
|
|
|
)
|
|
|
|
|
|
).tolist()
|
|
|
|
|
|
)
|
|
|
|
|
|
# 画杆高
|
|
|
|
|
|
cad.model.AddLine(tower_start, tower_end)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
draw_count += 1
|
2022-07-24 17:18:57 +08:00
|
|
|
|
# 画弧垂
|
|
|
|
|
|
if not is_first_tower: # 从第二基塔开始画
|
|
|
|
|
|
draw_k = tower_info.back_k
|
|
|
|
|
|
span = tower_info.mileage_in_s - last_tower_info.mileage_in_s
|
|
|
|
|
|
last_tower_fiting = last_tower_info.fitting
|
|
|
|
|
|
last_tower_fitting_length = fitting_length_dict[last_tower_fiting]
|
|
|
|
|
|
if last_tower_info.is_tension_tower:
|
|
|
|
|
|
last_tower_fitting_length = 0
|
|
|
|
|
|
tower_fitting = tower_info.fitting
|
|
|
|
|
|
tower_fitting_length = fitting_length_dict[tower_fitting]
|
|
|
|
|
|
if tower_info.is_tension_tower:
|
|
|
|
|
|
tower_fitting_length = 0
|
|
|
|
|
|
last_tower_height = last_tower_info.tower_height
|
|
|
|
|
|
last_foundation_low = last_tower_info.foundation_low
|
|
|
|
|
|
# 挂点高差
|
|
|
|
|
|
fiting_altitude_off = (
|
|
|
|
|
|
tower_info.altitude_off
|
|
|
|
|
|
+ (tower_height - foundation_low - tower_fitting_length)
|
|
|
|
|
|
- (
|
|
|
|
|
|
last_tower_height
|
|
|
|
|
|
- last_foundation_low
|
|
|
|
|
|
- last_tower_fitting_length
|
|
|
|
|
|
)
|
|
|
|
|
|
) # 前侧高为正
|
|
|
|
|
|
# 画导线弧垂
|
|
|
|
|
|
x = np.linspace(0, span, int(span), endpoint=True)
|
|
|
|
|
|
curve = curve_fun(x, span, draw_k, fiting_altitude_off)
|
|
|
|
|
|
draw_curve_x = (first_tower_point[0]) + (
|
|
|
|
|
|
x + accu_mileage - span
|
|
|
|
|
|
) / 5
|
|
|
|
|
|
draw_curve_y = (
|
|
|
|
|
|
first_tower_point[1]
|
|
|
|
|
|
+ (
|
|
|
|
|
|
+curve
|
|
|
|
|
|
+ accu_altitude_off
|
|
|
|
|
|
- tower_info.altitude_off
|
|
|
|
|
|
- last_tower_info.foundation_low
|
|
|
|
|
|
+ last_tower_info.tower_height
|
|
|
|
|
|
- last_tower_fitting_length
|
|
|
|
|
|
)
|
|
|
|
|
|
* 2
|
|
|
|
|
|
)
|
|
|
|
|
|
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_ground_curve_y = draw_curve_y - 18 * 2 # 切地线
|
|
|
|
|
|
draw_tree_curve_y = draw_curve_y - 13.5 * 2 # 切树线
|
|
|
|
|
|
draw_point = np.hstack(
|
|
|
|
|
|
(draw_curve_x, draw_curve_y, np.zeros((len(draw_curve_x), 1)))
|
|
|
|
|
|
)
|
|
|
|
|
|
draw_ground_curve_point = np.hstack(
|
|
|
|
|
|
(
|
|
|
|
|
|
draw_curve_x,
|
|
|
|
|
|
draw_ground_curve_y,
|
|
|
|
|
|
np.zeros((len(draw_curve_x), 1)),
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
draw_tree_curve_point = np.hstack(
|
|
|
|
|
|
(
|
|
|
|
|
|
draw_curve_x,
|
|
|
|
|
|
draw_tree_curve_y,
|
|
|
|
|
|
np.zeros((len(draw_curve_x), 1)),
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
added_curve = cad.model.AddPolyLine(
|
|
|
|
|
|
draw_point.reshape(1, draw_curve_x.shape[0] * 3)[0]
|
|
|
|
|
|
)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
set_true_color(added_curve, Color)
|
2022-07-24 17:18:57 +08:00
|
|
|
|
added_ground_curve = cad.model.AddPolyLine(
|
|
|
|
|
|
draw_ground_curve_point.reshape(
|
|
|
|
|
|
1, draw_ground_curve_y.shape[0] * 3
|
|
|
|
|
|
)[0]
|
|
|
|
|
|
)
|
|
|
|
|
|
set_true_color(added_ground_curve, 122, 219, 245)
|
|
|
|
|
|
added_tree_curve = cad.model.AddPolyLine(
|
|
|
|
|
|
draw_tree_curve_point.reshape(
|
|
|
|
|
|
1, draw_tree_curve_y.shape[0] * 3
|
|
|
|
|
|
)[0]
|
|
|
|
|
|
)
|
|
|
|
|
|
set_true_color(added_tree_curve, 116, 230, 165)
|
|
|
|
|
|
is_first_tower = False
|
|
|
|
|
|
last_tower_info = tower_info
|
|
|
|
|
|
doc.SaveAs(save_to)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main1():
|
2022-07-24 16:47:21 +08:00
|
|
|
|
s_file = SFile()
|
|
|
|
|
|
s_file.open(r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\S033.DAT")
|
|
|
|
|
|
# with xw.App(visible=False) as app:
|
|
|
|
|
|
# wb_string_impact = app.books.open("特高压耐张串影响弧垂计算(送电室2018人员版)1122-1218.xls")
|
|
|
|
|
|
# stringImpactExcel = StringImpactExcel()
|
|
|
|
|
|
# stringImpactExcel.read(wb_string_impact)
|
2022-07-24 17:18:57 +08:00
|
|
|
|
with Apyautocad(create_if_not_exists=True, visible=False, auto_close=False) as cad:
|
2022-07-24 16:47:21 +08:00
|
|
|
|
doc = cad.app.Documents.Open(r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg")
|
|
|
|
|
|
sleep(1)
|
|
|
|
|
|
z_file_path = deduce_zfile_from_cad_path(
|
|
|
|
|
|
r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg"
|
|
|
|
|
|
)
|
|
|
|
|
|
z_point = plane_z_origin(z_file_path)
|
|
|
|
|
|
fitting_file_path = deduce_fit_db_from_cad_path(
|
|
|
|
|
|
r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg"
|
|
|
|
|
|
)
|
|
|
|
|
|
fitting = Fitting(fitting_file_path)
|
|
|
|
|
|
fitting_length_dict = fitting.fitting_length_dic
|
|
|
|
|
|
first_tower_point = z_point
|
|
|
|
|
|
last_tower_info = None # 上一个塔位信息
|
|
|
|
|
|
accu_mileage = 0 # 累计档距
|
|
|
|
|
|
accu_altitude_off = 0 # 累计高差
|
|
|
|
|
|
is_first_tower = True
|
|
|
|
|
|
for tower in s_file.tower_dic:
|
|
|
|
|
|
tower_info = s_file.tower_dic[tower]
|
|
|
|
|
|
if not last_tower_info:
|
|
|
|
|
|
last_tower_info = tower_info
|
|
|
|
|
|
foundation_low = tower_info.foundation_low
|
|
|
|
|
|
accu_mileage = (
|
|
|
|
|
|
accu_mileage + tower_info.mileage_in_s - last_tower_info.mileage_in_s
|
|
|
|
|
|
)
|
|
|
|
|
|
accu_altitude_off = accu_altitude_off + tower_info.altitude_off # 中心桩高程
|
|
|
|
|
|
tower_start = APoint(
|
|
|
|
|
|
*(
|
|
|
|
|
|
(
|
|
|
|
|
|
first_tower_point
|
|
|
|
|
|
+ np.array(
|
|
|
|
|
|
[accu_mileage / 5, (accu_altitude_off - foundation_low) * 2]
|
|
|
|
|
|
)
|
|
|
|
|
|
).tolist()
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
tower_height = tower_info.tower_height
|
|
|
|
|
|
tower_end = APoint(
|
|
|
|
|
|
*(
|
|
|
|
|
|
first_tower_point
|
|
|
|
|
|
+ np.array(
|
|
|
|
|
|
[
|
|
|
|
|
|
accu_mileage / 5,
|
|
|
|
|
|
(accu_altitude_off + tower_height - foundation_low) * 2,
|
|
|
|
|
|
]
|
|
|
|
|
|
)
|
|
|
|
|
|
).tolist()
|
|
|
|
|
|
)
|
|
|
|
|
|
# 画杆高
|
|
|
|
|
|
cad.model.AddLine(tower_start, tower_end)
|
|
|
|
|
|
# 画弧垂
|
|
|
|
|
|
if not is_first_tower: # 从第二基塔开始画
|
|
|
|
|
|
draw_k = tower_info.back_k
|
|
|
|
|
|
span = tower_info.mileage_in_s - last_tower_info.mileage_in_s
|
|
|
|
|
|
last_tower_fiting = last_tower_info.fitting
|
|
|
|
|
|
last_tower_fitting_length = fitting_length_dict[last_tower_fiting]
|
|
|
|
|
|
if last_tower_info.is_tension_tower:
|
|
|
|
|
|
last_tower_fitting_length = 0
|
|
|
|
|
|
tower_fitting = tower_info.fitting
|
|
|
|
|
|
tower_fitting_length = fitting_length_dict[tower_fitting]
|
|
|
|
|
|
if tower_info.is_tension_tower:
|
|
|
|
|
|
tower_fitting_length = 0
|
|
|
|
|
|
last_tower_height = last_tower_info.tower_height
|
|
|
|
|
|
last_foundation_low = last_tower_info.foundation_low
|
|
|
|
|
|
# 挂点高差
|
|
|
|
|
|
fiting_altitude_off = (
|
|
|
|
|
|
tower_info.altitude_off
|
|
|
|
|
|
+ (tower_height - foundation_low - tower_fitting_length)
|
|
|
|
|
|
- (
|
|
|
|
|
|
last_tower_height
|
|
|
|
|
|
- last_foundation_low
|
|
|
|
|
|
- last_tower_fitting_length
|
|
|
|
|
|
)
|
|
|
|
|
|
) # 前侧高为正
|
|
|
|
|
|
# 画导线弧垂
|
|
|
|
|
|
x = np.linspace(0, span, int(span), endpoint=True)
|
|
|
|
|
|
curve = curve_fun(x, span, draw_k, fiting_altitude_off)
|
|
|
|
|
|
draw_curve_x = (first_tower_point[0]) + (x + accu_mileage - span) / 5
|
|
|
|
|
|
draw_curve_y = (
|
|
|
|
|
|
first_tower_point[1]
|
|
|
|
|
|
+ (
|
|
|
|
|
|
+curve
|
|
|
|
|
|
+ accu_altitude_off
|
|
|
|
|
|
- tower_info.altitude_off
|
|
|
|
|
|
- last_tower_info.foundation_low
|
|
|
|
|
|
+ last_tower_info.tower_height
|
|
|
|
|
|
- last_tower_fitting_length
|
|
|
|
|
|
)
|
|
|
|
|
|
* 2
|
|
|
|
|
|
)
|
|
|
|
|
|
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_ground_curve_y = draw_curve_y - 18 * 2 # 切地线
|
|
|
|
|
|
draw_tree_curve_y = draw_curve_y - 13.5 * 2 # 切树线
|
|
|
|
|
|
draw_point = np.hstack(
|
|
|
|
|
|
(draw_curve_x, draw_curve_y, np.zeros((len(draw_curve_x), 1)))
|
|
|
|
|
|
)
|
|
|
|
|
|
draw_ground_curve_point = np.hstack(
|
|
|
|
|
|
(
|
|
|
|
|
|
draw_curve_x,
|
|
|
|
|
|
draw_ground_curve_y,
|
|
|
|
|
|
np.zeros((len(draw_curve_x), 1)),
|
|
|
|
|
|
)
|
|
|
|
|
|
)
|
|
|
|
|
|
draw_tree_curve_point = np.hstack(
|
|
|
|
|
|
(draw_curve_x, draw_tree_curve_y, np.zeros((len(draw_curve_x), 1)))
|
|
|
|
|
|
)
|
2022-07-24 17:18:57 +08:00
|
|
|
|
added_curve = cad.model.AddPolyLine(
|
2022-07-24 16:47:21 +08:00
|
|
|
|
draw_point.reshape(1, draw_curve_x.shape[0] * 3)[0]
|
|
|
|
|
|
)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
set_true_color(added_curve, *ColorEnume.wire_color_rgb)
|
2022-07-24 17:18:57 +08:00
|
|
|
|
added_ground_curve = cad.model.AddPolyLine(
|
|
|
|
|
|
draw_ground_curve_point.reshape(
|
|
|
|
|
|
1, draw_ground_curve_y.shape[0] * 3
|
|
|
|
|
|
)[0]
|
2022-07-24 16:47:21 +08:00
|
|
|
|
)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
|
2022-07-24 17:18:57 +08:00
|
|
|
|
added_tree_curve = cad.model.AddPolyLine(
|
2022-07-24 16:47:21 +08:00
|
|
|
|
draw_tree_curve_point.reshape(1, draw_tree_curve_y.shape[0] * 3)[0]
|
|
|
|
|
|
)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
2022-07-24 16:47:21 +08:00
|
|
|
|
is_first_tower = False
|
|
|
|
|
|
last_tower_info = tower_info
|
|
|
|
|
|
doc.SaveAs(r"d:\工程\金上线\code\考虑耐张串重弧垂\T033A.dwg")
|
|
|
|
|
|
|
|
|
|
|
|
|
2022-07-24 17:18:57 +08:00
|
|
|
|
def main():
|
2022-07-25 02:05:08 +08:00
|
|
|
|
# continousePlate = ContinuousPlate(
|
|
|
|
|
|
# r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg",
|
|
|
|
|
|
# r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\S033.DAT",
|
|
|
|
|
|
# "N3339",
|
|
|
|
|
|
# 7,
|
|
|
|
|
|
# )
|
|
|
|
|
|
# continousePlate.draw(r"d:\工程\金上线\code\考虑耐张串重弧垂\T033A.dwg")
|
|
|
|
|
|
string_impact_plate = StringImpactPlate(
|
2022-07-24 17:18:57 +08:00
|
|
|
|
r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\033A.dwg",
|
|
|
|
|
|
r"d:\工程\金上线\排位\定位完排位\PW.0706\J33-J49\S033.DAT",
|
2022-07-25 03:47:28 +08:00
|
|
|
|
"N3339",
|
2022-07-25 02:05:08 +08:00
|
|
|
|
"",
|
|
|
|
|
|
"",
|
2022-07-24 17:18:57 +08:00
|
|
|
|
)
|
2022-07-25 02:05:08 +08:00
|
|
|
|
string_impact_plate.draw()
|
2022-07-24 17:18:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
|
|
main()
|
|
|
|
|
|
print("Finished.")
|