Files
Pier_v1/Code/검토수정/스크립트/c1_footing_other.py
T
ahnyongjooandClaude Sonnet 5.5 964a841de1 chore(rebar): Pier_T_rebar 작업 폴더 초기 구성 및 외부 의존 파일 통합
- Code\rebar_pipeline, review_pipeline, pier-program을 정션에서 실제 폴더로 전환
- Code\rhino_mcp 및 CLAUDE_rhino배경.md 추가, .mcp.json은 PYTHONPATH로 새 위치 사용
- pier-program 내부 .git 제거(이력은 backup\pier-program_20261028.bundle에 보관)
- worktree 가이드 반영(CLAUDE.local.md, HANDOFF.md)
- D:\Rhino-MCP 경로 참조를 새 위치로 치환

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-10-28 11:20:18 +09:00

173 lines
7.8 KiB
Python

#! python3
# Footing rebar of Sanoe and Okseong under the user rule (2026-10-23/26): outermost bars on the drawing lines
# (top: centre 100 below top, bottom: centre 150 above bottom), inner bars touch them (sum of radii), U legs end on the outer
# top line (drawing leg length = line to line). Equal bar diameters in both directions in both bridges -> no designer query.
# plus C-1 bend radius for the listed footing marks. Results are saved under NEW names (..._수정2_20261023.3dm).
import sys, os, json, math, collections, traceback
sys.path.insert(0, r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work")
import c1_core
import Rhino
from Rhino.Geometry import Transform, Vector3d, PolyCurve, Point3d
from c1_core import BASE, plan_curve, make_pipe, required_rc, _retarget
DATE_TXT = "2026-10-26"
OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_footing_other.json"
# per mark: dz, expected z range before (rel. footing bottom), end_z (U leg tip, None = keep after translation)
JOBS = {
"sanoe": {
"src": os.path.join(BASE, "검토_산외교P1", "산외교P1 G5_수정_20261023.3dm"),
"dst": os.path.join(BASE, "검토_산외교P1", "산외교P1 G5_수정2_20261023.3dm"),
"plan": {
"B1": (-22.5, (2422.5, 2422.5), None),
"B4": (6.5, (2377.5, 2377.5), None),
"B3": (22.5, (127.5, 127.5), None),
"B2": (22.5, (127.5, 2377.5), 2400.0),
"B6": (-0.5, (172.5, 172.5), None),
"B5": (-0.5, (172.5, 2422.5), 2400.0),
},
"rfix": {"B2", "B5"},
"note": "footing: B1 z2400, B4 z2384, B3/B2 z150 (B2 legs end 2400), B6/B5 z172 (B5 legs end 2400); C-1 R for B2,B5",
},
"okseong": {
"src": os.path.join(BASE, "검토_옥성교P1", "옥성교P1_G5_수정_20261023.3dm"),
"dst": os.path.join(BASE, "검토_옥성교P1", "옥성교P1_G5_수정2_20261023.3dm"),
"plan": {
"B5": (-6.5, (1102.5, 2077.5), None),
"B7": (-6.5, (1102.5, 2077.5), None),
"B6": (6.5, (172.5, 2122.5), 2100.0),
"B8": (6.5, (172.5, 2122.5), 2100.0),
},
"rfix": {"B9", "B10", "B11", "B12"},
"note": "footing: B5/B7 z2071, B6/B8 z179 (legs end 2100), B1-B4 unchanged on lines 2100/150; C-1 R for B9-B12",
},
}
res = {}
def zr(g):
b = g.GetBoundingBox(True)
return b.Min.Z, b.Max.Z
def run_one(key, job):
r = {}
doc = Rhino.RhinoDoc.OpenHeadless(job["src"])
tol = doc.ModelAbsoluteTolerance
st = Rhino.DocObjects.ObjectEnumeratorSettings()
st.HiddenObjects = True
st.LockedObjects = True
st.NormalObjects = True
lay = {l.Index: l.FullPath for l in doc.Layers}
r["objects_before"] = doc.Objects.Count
fbot = [o for o in doc.Objects.GetObjectList(st) if o.Attributes.Name == "P1-FT"][0].Geometry.GetBoundingBox(True).Min.Z
breps = collections.defaultdict(list)
curves = []
for o in doc.Objects.GetObjectList(st):
g = o.Geometry
L = lay.get(o.Attributes.LayerIndex, "")
if isinstance(g, Rhino.Geometry.Brep) and "철근" in L:
breps[o.Attributes.Name].append(o)
elif isinstance(g, Rhino.Geometry.Curve) and "중심선" in L and (o.Attributes.GetUserString("mark") or "").upper().startswith("B"):
curves.append(o)
stat = collections.Counter()
plan = job["plan"]
for o in curves:
a = o.Attributes
m = a.GetUserString("mark")
if m not in plan and m not in job["rfix"]:
continue
dia = a.GetUserString("dia")
nb = breps.get(a.Name.replace("-RC-", "-R-"), [])
if len(nb) != 1:
stat[m + "_no_brep"] += 1
continue
cid, bid = o.Id, nb[0].Id
c = o.Geometry.Duplicate()
did = []
rebuild = False
dz = 0.0
if m in plan:
dz, exp, end_z = plan[m]
z0, z1 = zr(c)
if abs(z0 - fbot - exp[0]) > 0.6 or abs(z1 - fbot - exp[1]) > 0.6:
stat[m + "_unexpected_z"] += 1
continue
c.Transform(Transform.Translation(Vector3d(0, 0, dz)))
did.append("dz %+.1f" % dz)
if end_z is not None and isinstance(c, PolyCurve):
tz = fbot + end_z
n = c.SegmentCount
s0, sN = c.SegmentCurve(0), c.SegmentCurve(n - 1)
if abs(s0.TangentAtStart.Z) < 0.999 or abs(sN.TangentAtEnd.Z) < 0.999:
stat[m + "_legs_not_vertical"] += 1
continue
zs0, zsN = s0.PointAtStart.Z, sN.PointAtEnd.Z
if abs(zs0 - tz) > 1e-6 or abs(zsN - tz) > 1e-6:
segs = [c.SegmentCurve(i).DuplicateCurve() for i in range(n)]
p0, pN = segs[0].PointAtStart, segs[-1].PointAtEnd
segs[0] = _retarget(segs[0], start=Point3d(p0.X, p0.Y, tz))
segs[-1] = _retarget(segs[-1], end=Point3d(pN.X, pN.Y, tz))
pc = PolyCurve()
for s in segs:
pc.Append(s)
c = pc
did.append("legs end z %.1f" % end_z)
rebuild = True
if m in job["rfix"] and isinstance(c, PolyCurve):
pc, info = plan_curve(c, dia)
if info["status"] == "ok":
c = pc
did.append("R %.2f" % info["req"])
rebuild = True
elif info["status"] != "unchanged":
stat[m + "_rfix_" + info["status"]] += 1
if not did:
continue
if rebuild:
req, d = required_rc(dia)
pipes = make_pipe(c, d, tol)
if not pipes or len(pipes) != 1 or not pipes[0].IsSolid:
stat[m + "_pipe_fail"] += 1
continue
vol = Rhino.Geometry.VolumeMassProperties.Compute(pipes[0]).Volume
if abs(vol / (math.pi * (d / 2.0) ** 2 * c.GetLength()) - 1.0) > 0.002:
stat[m + "_volume_off"] += 1
continue
newb = pipes[0]
else:
newb = doc.Objects.FindId(bid).Geometry.Duplicate()
newb.Transform(Transform.Translation(Vector3d(0, 0, dz)))
if not (doc.Objects.Replace(cid, c) and doc.Objects.Replace(bid, newb)):
stat[m + "_replace_failed"] += 1
continue
for oid in (cid, bid):
ro = doc.Objects.FindId(oid)
at = ro.Attributes.Duplicate()
at.SetUserString("footing_fix", "; ".join(did) + " (" + DATE_TXT + ", user rule: outermost on drawing lines, inner bars inside)")
doc.Objects.ModifyAttributes(ro, at, True)
stat[m + "_done"] += 1
after = collections.defaultdict(list)
for o in doc.Objects.GetObjectList(st):
if isinstance(o.Geometry, Rhino.Geometry.Curve) and "중심선" in lay.get(o.Attributes.LayerIndex, "") and (o.Attributes.GetUserString("mark") or "").upper().startswith("B"):
after[o.Attributes.GetUserString("mark")].append(zr(o.Geometry))
r["z_after_rel"] = {mm: [round(min(z[0] for z in v) - fbot, 2), round(max(z[1] for z in v) - fbot, 2)] for mm, v in after.items()}
r["stat"] = dict(stat)
doc.Strings.SetString("수정일", DATE_TXT)
prev = doc.Strings.GetValue("수정내용") or ""
doc.Strings.SetString("수정내용", (prev + " | " if prev else "") + job["note"])
r["objects_after"] = doc.Objects.Count
r["saved"] = bool(doc.WriteFile(job["dst"], Rhino.FileIO.FileWriteOptions()))
r["out"] = job["dst"]
doc.Dispose()
return r
for key, job in JOBS.items():
try:
res[key] = run_one(key, job)
except Exception:
res[key] = {"error": traceback.format_exc()}
json.dump(res, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
res["done"] = True
json.dump(res, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1)