准备解决中间有耐张段的情况。
This commit is contained in:
parent
ce1ff065d1
commit
2109957df1
52
PWFile.py
52
PWFile.py
|
|
@ -12,6 +12,17 @@ from time import sleep
|
|||
from attrs import define
|
||||
from typing import List
|
||||
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
|
||||
class SEntry:
|
||||
|
|
@ -218,20 +229,25 @@ class StringImpactPlate:
|
|||
return index
|
||||
|
||||
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)))
|
||||
added_curve = cad.model.AddPolyLine(plot_vector)
|
||||
added_curve.Layer = custom_layer.Name
|
||||
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)))
|
||||
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)
|
||||
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)
|
||||
added_tree_curve.Layer = custom_layer.Name
|
||||
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
||||
|
||||
def _draw_action(self, excel_app, cad):
|
||||
# 计算代表档距
|
||||
# TODO 计算代表档距
|
||||
s_file = SFile()
|
||||
s_file.open(self._s_file_path)
|
||||
tower_dict = s_file.tower_dic
|
||||
|
|
@ -390,6 +406,7 @@ class ContinuousPlate:
|
|||
self.cad = cad
|
||||
doc = cad.app.Documents.Open(dwg_file_path)
|
||||
sleep(1)
|
||||
custom_layer = get_layer_if_not_exist_create_it(doc, "123custom_layer")
|
||||
tower_dict = s_file.tower_dic
|
||||
z_file_path = deduce_zfile_from_cad_path(dwg_file_path)
|
||||
z_point = plane_z_origin(z_file_path)
|
||||
|
|
@ -441,6 +458,7 @@ class ContinuousPlate:
|
|||
added_represented_span_text,
|
||||
ColorEnume.representive_span_text_color_rgb,
|
||||
)
|
||||
added_represented_span_text.Layer = custom_layer.Name
|
||||
if is_first_tower: # 是否是开始画的第一个塔。
|
||||
accu_altitude_off = 0
|
||||
else:
|
||||
|
|
@ -479,14 +497,16 @@ class ContinuousPlate:
|
|||
tower_pole = cad.model.AddPolyLine(
|
||||
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)
|
||||
set_true_color(tower_pole, 0, 255, 255)
|
||||
# 画塔名和呼高
|
||||
cad.model.AddText(
|
||||
added_tower_name = cad.model.AddText(
|
||||
f"{tower_info.tower_name}",
|
||||
APoint(*(np_tower_end + np.array([-5, 13])).tolist()),
|
||||
5,
|
||||
)
|
||||
added_tower_name.Layer = custom_layer.Name
|
||||
if (
|
||||
abs(math.floor(tower_info.tower_height) - tower_info.tower_height)
|
||||
< 0.1
|
||||
|
|
@ -494,11 +514,12 @@ class ContinuousPlate:
|
|||
draw_tower_height_str = f"{tower_info.tower_height:.0f}"
|
||||
else:
|
||||
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}",
|
||||
APoint(*(np_tower_end + np.array([-5, 5])).tolist()),
|
||||
5,
|
||||
)
|
||||
added_hugao.Layer = custom_layer.Name
|
||||
draw_count += 1
|
||||
# 画弧垂
|
||||
if not is_first_tower: # 从第二基塔开始画
|
||||
|
|
@ -544,7 +565,8 @@ class ContinuousPlate:
|
|||
)
|
||||
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 # 切地线
|
||||
# TODO 应该读规程的
|
||||
draw_ground_curve_y = draw_curve_y - 16 * 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)))
|
||||
|
|
@ -566,18 +588,21 @@ class ContinuousPlate:
|
|||
added_curve = cad.model.AddPolyLine(
|
||||
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)
|
||||
added_ground_curve = cad.model.AddPolyLine(
|
||||
draw_ground_curve_point.reshape(
|
||||
1, draw_ground_curve_y.shape[0] * 3
|
||||
)[0]
|
||||
)
|
||||
added_ground_curve.Layer = custom_layer.Name
|
||||
set_true_color(added_ground_curve, *ColorEnume.ground_color_rgb)
|
||||
added_tree_curve = cad.model.AddPolyLine(
|
||||
draw_tree_curve_point.reshape(
|
||||
1, draw_tree_curve_y.shape[0] * 3
|
||||
)[0]
|
||||
)
|
||||
added_tree_curve.Layer = custom_layer.Name
|
||||
set_true_color(added_tree_curve, *ColorEnume.tree_color_rgb)
|
||||
# 画档距
|
||||
span_text_insert_point = np.array(
|
||||
|
|
@ -586,7 +611,23 @@ class ContinuousPlate:
|
|||
added_span_text = cad.model.AddText(
|
||||
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)
|
||||
added_span_text.Layer = custom_layer.Name
|
||||
is_first_tower = False
|
||||
last_tower_info = tower_info
|
||||
|
||||
|
|
@ -653,6 +694,7 @@ class ControlFile:
|
|||
string_impact_plate.draw()
|
||||
cad = continuous_plate.cad
|
||||
cad.doc.SaveAs(self.get_zt_dwg_file_path())
|
||||
cad.doc.Utility.Prompt("断面已生成。\n")
|
||||
# # 画完后再打开
|
||||
# cad = None
|
||||
# continousePlate = None
|
||||
|
|
|
|||
Loading…
Reference in New Issue