-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdimension_utils.py
More file actions
110 lines (93 loc) · 2.71 KB
/
Copy pathdimension_utils.py
File metadata and controls
110 lines (93 loc) · 2.71 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"""
dimension_utils.py
AutoBridge-CAD 尺寸标注与文字绘制模块
负责绘制跨径标注、结构轴线以及标高符号等
"""
from typing import List
from ezdxf.enums import TextEntityAlignment
from geometry_utils import calculate_pier_positions, calculate_span_centers
def add_span_labels(
msp,
spans: List[float],
text_height: float = 1.5,
y_offset: float = 1.5,
) -> None:
"""
在各跨主梁上方居中绘制跨径文字标注 (如 "Span 1: 30.0m")
:param msp: ezdxf modelspace 对象
:param spans: 跨径列表 [l1, l2, ...]
:param text_height: 文字字高
:param y_offset: 距离主梁顶面的 Y 轴偏移量
"""
centers = calculate_span_centers(spans)
for i, (span, x_center) in enumerate(zip(spans, centers)):
label_text = f"Span {i+1}: {span:.1f}m"
msp.add_text(
label_text,
dxfattribs={
'height': text_height,
'layer': 'DIMENSION',
},
).set_placement(
(x_center, y_offset),
align=TextEntityAlignment.CENTER,
)
def add_pier_axes(
msp,
spans: List[float],
beam_h: float,
pier_h: float,
extension: float = 2.0,
) -> None:
"""
在每个中间桥墩中心位置绘制点划线结构轴线 (AXIS 图层)
:param msp: ezdxf modelspace 对象
:param spans: 跨径列表
:param beam_h: 主梁高度
:param pier_h: 桥墩高度
:param extension: 轴线超出结构上下边界的延伸长度
"""
pier_x_positions = calculate_pier_positions(spans)
y_top = extension
y_bottom = -beam_h - pier_h - extension
for x_pos in pier_x_positions:
msp.add_line(
(x_pos, y_top),
(x_pos, y_bottom),
dxfattribs={'layer': 'AXIS'},
)
def add_title_block(
msp,
total_length: float,
title: str = "桥梁总体布置图",
scale_text: str = "1:100",
) -> None:
"""
在图纸下方绘制主标题与比例说明
:param msp: ezdxf modelspace 对象
:param total_length: 桥梁总长 (用于确定标题居中位置)
:param title: 图纸主标题
:param scale_text: 比例文字
"""
x_center = total_length / 2.0
y_pos = -25.0 # 放置在图纸下方区域
msp.add_text(
title,
dxfattribs={
'height': 3.0,
'layer': 'DIMENSION',
},
).set_placement(
(x_center, y_pos),
align=TextEntityAlignment.CENTER,
)
msp.add_text(
f"比例 {scale_text}",
dxfattribs={
'height': 1.5,
'layer': 'DIMENSION',
},
).set_placement(
(x_center, y_pos - 2.5),
align=TextEntityAlignment.CENTER,
)