Refine beam section figure and derive As from bars
- Derive As from the provided longitudinal bars instead of taking it as input; drop the redundant As_bars output and update tests. - Draw a fixed schematic 1 in cover and pin the bottom bars to the stirrup's bottom leg so the figure no longer depends on cover or d. - Fixed stirrup stroke with a rounded 3 pt corner radius. - Right-align the figure, constrain its caption to the image width, and shorten the caption to "Beam cross-section". - Document input.yaml fields.
This commit is contained in:
parent
25f66bb4da
commit
759d5e3bae
8 changed files with 638 additions and 680 deletions
|
|
@ -6,11 +6,15 @@ from pathlib import Path
|
|||
|
||||
HERE = Path(__file__).resolve().parent
|
||||
|
||||
SCALE = 14.0 # points per inch
|
||||
LEFT = 80.0
|
||||
RIGHT = 110.0
|
||||
TOP = 34.0
|
||||
BOTTOM = 44.0
|
||||
SCALE = 9.5 # points per inch
|
||||
LEFT = 48.0
|
||||
RIGHT = 56.0
|
||||
TOP = 28.0
|
||||
BOTTOM = 38.0
|
||||
|
||||
STIRRUP_STROKE = 2.0 # drawn stirrup line width, points
|
||||
STIRRUP_RADIUS = 3.0 # drawn stirrup corner radius, points
|
||||
DRAW_COVER = 1.0 # schematic cover shown in the drawing, inches
|
||||
|
||||
MUTED = 'rgb("#626b73")'
|
||||
|
||||
|
|
@ -19,9 +23,9 @@ def _f(value: float) -> str:
|
|||
return f"{value:.4g}"
|
||||
|
||||
|
||||
def _centers(size: float, number: int, bw: float, cover: float, stirrup_db: float) -> list[float]:
|
||||
def _centers(size: float, number: int, bw: float, edge: float) -> list[float]:
|
||||
half = size / 2.0
|
||||
left = cover + stirrup_db + half
|
||||
left = edge + half
|
||||
right = bw - left
|
||||
if number == 1:
|
||||
return [bw / 2.0]
|
||||
|
|
@ -32,10 +36,7 @@ def render(values: dict) -> str:
|
|||
s = SCALE
|
||||
bw = float(values["bw"])
|
||||
h = float(values["h"])
|
||||
d = float(values["d"])
|
||||
cover = float(values["cover"])
|
||||
stirrup_size = int(values["stirrup_size"])
|
||||
stirrup_db = float(values["stirrup_db"])
|
||||
stirrup_spacing = float(values["stirrup_spacing"])
|
||||
bar_size = int(values["bar_size"])
|
||||
bar_db = float(values["bar_db"])
|
||||
|
|
@ -58,11 +59,12 @@ def render(values: dict) -> str:
|
|||
def sy(y_in: float) -> float:
|
||||
return oy + (h - y_in) * s
|
||||
|
||||
inset = cover + stirrup_db / 2.0
|
||||
y_bottom = h - d
|
||||
bottom = _centers(bar_db, n_bars, bw, cover, stirrup_db)
|
||||
top_y = h - (cover + stirrup_db + top_bar_db / 2.0)
|
||||
top = _centers(top_bar_db, n_top_bars, bw, cover, stirrup_db)
|
||||
edge = DRAW_COVER + STIRRUP_STROKE / s
|
||||
inset = DRAW_COVER + STIRRUP_STROKE / s / 2.0
|
||||
y_bottom = edge + bar_db / 2.0
|
||||
bottom = _centers(bar_db, n_bars, bw, edge)
|
||||
top_y = h - (edge + top_bar_db / 2.0)
|
||||
top = _centers(top_bar_db, n_top_bars, bw, edge)
|
||||
|
||||
lines: list[str] = []
|
||||
add = lines.append
|
||||
|
|
@ -77,7 +79,7 @@ def render(values: dict) -> str:
|
|||
add(
|
||||
f" #place(dx: {_f(sx(inset))}pt, dy: {_f(sy(h - inset))}pt, "
|
||||
f"rect(width: {_f((bw - 2.0 * inset) * s)}pt, height: {_f((h - 2.0 * inset) * s)}pt, "
|
||||
f"radius: 1.5pt, stroke: {_f(stirrup_db * s)}pt + black))"
|
||||
f"radius: {_f(STIRRUP_RADIUS)}pt, stroke: {_f(STIRRUP_STROKE)}pt + black))"
|
||||
)
|
||||
|
||||
for x_in in bottom:
|
||||
|
|
@ -100,47 +102,31 @@ def render(values: dict) -> str:
|
|||
)
|
||||
for tick in (ox, ox + w_sec):
|
||||
add(
|
||||
f" #place(line(start: ({_f(tick)}pt, {_f(dim_y - 4)}pt), end: ({_f(tick)}pt, {_f(dim_y + 4)}pt), "
|
||||
f" #place(line(start: ({_f(tick)}pt, {_f(dim_y - 3)}pt), end: ({_f(tick)}pt, {_f(dim_y + 3)}pt), "
|
||||
f"stroke: 0.6pt + black))"
|
||||
)
|
||||
add(
|
||||
f" #place(dx: {_f(ox)}pt, dy: {_f(dim_y + 3)}pt, "
|
||||
f'box(width: {_f(w_sec)}pt, align(center)[$b_w = {_f(bw)} " in"$]))'
|
||||
f'box(width: {_f(w_sec)}pt, align(center, text(size: 7pt)[$b_w = {_f(bw)} " in"$])))'
|
||||
)
|
||||
|
||||
x_h = ox - 12.0
|
||||
x_h = ox - 6.0
|
||||
add(
|
||||
f" #place(line(start: ({_f(x_h)}pt, {_f(oy)}pt), end: ({_f(x_h)}pt, {_f(oy + h_sec)}pt), "
|
||||
f"stroke: 0.6pt + black))"
|
||||
)
|
||||
for tick in (oy, oy + h_sec):
|
||||
add(
|
||||
f" #place(line(start: ({_f(x_h - 4)}pt, {_f(tick)}pt), end: ({_f(x_h + 4)}pt, {_f(tick)}pt), "
|
||||
f" #place(line(start: ({_f(x_h - 3)}pt, {_f(tick)}pt), end: ({_f(x_h + 3)}pt, {_f(tick)}pt), "
|
||||
f"stroke: 0.6pt + black))"
|
||||
)
|
||||
add(
|
||||
f" #place(dx: 2pt, dy: {_f(oy + h_sec / 2.0 - 5)}pt, "
|
||||
f'text(size: 8pt)[$h = {_f(h)} " in"$])'
|
||||
f" #place(dx: 0.5pt, dy: {_f(oy + h_sec / 2.0 - 3)}pt, "
|
||||
f'text(size: 7pt)[$h = {_f(h)} " in"$])'
|
||||
)
|
||||
|
||||
x_d = ox - 30.0
|
||||
d_end = oy + d * s
|
||||
add(
|
||||
f" #place(line(start: ({_f(x_d)}pt, {_f(oy)}pt), end: ({_f(x_d)}pt, {_f(d_end)}pt), "
|
||||
f"stroke: 0.6pt + black))"
|
||||
)
|
||||
for tick in (oy, d_end):
|
||||
add(
|
||||
f" #place(line(start: ({_f(x_d - 4)}pt, {_f(tick)}pt), end: ({_f(x_d + 4)}pt, {_f(tick)}pt), "
|
||||
f"stroke: 0.6pt + black))"
|
||||
)
|
||||
add(
|
||||
f" #place(dx: 2pt, dy: {_f((oy + d_end) / 2.0 - 5)}pt, "
|
||||
f'text(size: 8pt)[$d = {_f(d)} " in"$])'
|
||||
)
|
||||
|
||||
label_x = ox + w_sec + 16.0
|
||||
lead_x = ox + w_sec + 12.0
|
||||
label_x = ox + w_sec + 8.0
|
||||
lead_x = ox + w_sec + 5.0
|
||||
|
||||
def leader(fx: float, fy: float, lx: float, ly: float) -> None:
|
||||
add(
|
||||
|
|
@ -149,28 +135,22 @@ def render(values: dict) -> str:
|
|||
)
|
||||
add(f" #place(dx: {_f(fx - 1.5)}pt, dy: {_f(fy - 1.5)}pt, circle(radius: 1.5pt, fill: black))")
|
||||
|
||||
leader(sx(top[-1]), sy(top_y), lead_x, oy + 18.0)
|
||||
leader(sx(top[-1]), sy(top_y), lead_x, oy + 14.0)
|
||||
add(
|
||||
f" #place(dx: {_f(label_x)}pt, dy: {_f(oy + 12)}pt, "
|
||||
f"text(size: 7.5pt)[{n_top_bars} No. {top_bar_size} hanger \\ bars])"
|
||||
f" #place(dx: {_f(label_x)}pt, dy: {_f(oy + 9)}pt, "
|
||||
f"text(size: 7pt)[{n_top_bars} No. {top_bar_size} hanger \\ bars])"
|
||||
)
|
||||
|
||||
leader(sx(bw - inset), sy(h / 2.0), lead_x, oy + h_sec / 2.0 - 4.0)
|
||||
leader(sx(bw - inset), sy(h / 2.0), lead_x, oy + h_sec / 2.0 - 3.0)
|
||||
add(
|
||||
f" #place(dx: {_f(label_x)}pt, dy: {_f(oy + h_sec / 2.0 - 10)}pt, "
|
||||
f"text(size: 7.5pt)[No. {stirrup_size} stirrup \\ at {_f(stirrup_spacing)} in o.c.])"
|
||||
f" #place(dx: {_f(label_x)}pt, dy: {_f(oy + h_sec / 2.0 - 8)}pt, "
|
||||
f"text(size: 7pt)[No. {stirrup_size} stirrup \\ at {_f(stirrup_spacing)} in o.c.])"
|
||||
)
|
||||
|
||||
leader(sx(bottom[-1]), sy(y_bottom), lead_x, oy + h_sec - 18.0)
|
||||
leader(sx(bottom[-1]), sy(y_bottom), lead_x, oy + h_sec - 14.0)
|
||||
add(
|
||||
f" #place(dx: {_f(label_x)}pt, dy: {_f(oy + h_sec - 24)}pt, "
|
||||
f'text(size: 7.5pt)[{n_bars} No. {bar_size} bottom \\ $A_s = {_f(As)} " in"^2$])'
|
||||
)
|
||||
|
||||
leader(sx(inset), sy(inset), 40.0, oy + h_sec + 26.0)
|
||||
add(
|
||||
f" #place(dx: 2pt, dy: {_f(oy + h_sec + 30)}pt, "
|
||||
f'text(size: 7.5pt)[cover = {_f(cover)} in])'
|
||||
f" #place(dx: {_f(label_x)}pt, dy: {_f(oy + h_sec - 19)}pt, "
|
||||
f'text(size: 7pt)[{n_bars} No. {bar_size} bottom \\ $A_s = {_f(As)} " in"^2$])'
|
||||
)
|
||||
|
||||
add(" ]")
|
||||
|
|
|
|||
Loading…
Reference in a new issue