- 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>
149 lines
6.8 KiB
Python
149 lines
6.8 KiB
Python
#! python3
|
|
# Ungok footing rebar, user rule 2026-10-23: outermost bars B5 (top, centre at 100 below top) and B6 (bottom, centre 150 above
|
|
# bottom); all other main footing bars sit inside them, touching (centre distance = sum of radii).
|
|
# B5 2127->2100 (-27) | B1 2073->2072.5 | B6,B8 178->150 (-28) | B2,B4 122->177 (+55), B2 legs end at B1 level 2072.5
|
|
# plus C-1 bend radius for B1,B2,B3,B7,B10. B9 untouched. Source: ..._수정_20261023.3dm -> saved as ..._수정3_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-23"
|
|
FOLDER = os.path.join(BASE, "철근 모델랑 운곡교P1_바이브코딩")
|
|
SRC = os.path.join(FOLDER, "운곡교p1_수정_20261023.3dm")
|
|
DST = os.path.join(FOLDER, "운곡교p1_수정3_20261023.3dm")
|
|
OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_footing_ungok3.json"
|
|
# mark: (dz, expected z range before [rel. to footing bottom], target z range after)
|
|
PLAN = {
|
|
"B5": (-27.0, (1927.0, 2127.0), (1900.0, 2100.0)),
|
|
"B1": (-0.5, (1873.0, 2073.0), (1872.5, 2072.5)),
|
|
"B6": (-28.0, (178.0, 2128.0), (150.0, 2100.0)),
|
|
"B8": (-28.0, (178.0, 178.0), (150.0, 150.0)),
|
|
"B2": (55.0, (122.0, 2072.0), (177.0, 2072.5)),
|
|
"B4": (55.0, (122.0, 122.0), (177.0, 177.0)),
|
|
}
|
|
RFIX = {"B1", "B2", "B3", "B7", "B10"}
|
|
res = {}
|
|
|
|
|
|
def zr(g):
|
|
b = g.GetBoundingBox(True)
|
|
return b.Min.Z, b.Max.Z
|
|
|
|
|
|
try:
|
|
doc = Rhino.RhinoDoc.OpenHeadless(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}
|
|
res["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("host") == "P1-FT":
|
|
curves.append(o)
|
|
stat = collections.Counter()
|
|
for o in curves:
|
|
a = o.Attributes
|
|
m = a.GetUserString("mark")
|
|
if m not in PLAN and m not in 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
|
|
if m in PLAN:
|
|
dz, exp, tgt = 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 m == "B2":
|
|
# legs: first and last segment must be vertical; end them at B1 level (2072.5)
|
|
tz = fbot + 2072.5
|
|
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["B2_legs_not_vertical"] += 1
|
|
continue
|
|
segs = [c.SegmentCurve(i).DuplicateCurve() for i in range(n)]
|
|
p0 = segs[0].PointAtStart
|
|
pN = 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" % (tz - fbot))
|
|
rebuild = True
|
|
if m in 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 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()
|
|
if m in PLAN:
|
|
newb.Transform(Transform.Translation(Vector3d(0, 0, PLAN[m][0])))
|
|
if not did:
|
|
continue
|
|
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()
|
|
old = at.GetUserString("footing_fix") or ""
|
|
at.SetUserString("footing_fix", "; ".join(did) + " (" + DATE_TXT + ", user rule: B5 top cover 100 / B6 bottom 150, others 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("host") == "P1-FT":
|
|
after[o.Attributes.GetUserString("mark")].append(zr(o.Geometry))
|
|
res["z_after_rel"] = {m: [round(min(z[0] for z in v) - fbot, 2), round(max(z[1] for z in v) - fbot, 2)] for m, v in after.items()}
|
|
res["stat"] = dict(stat)
|
|
doc.Strings.SetString("수정일", DATE_TXT)
|
|
prev = doc.Strings.GetValue("수정내용") or ""
|
|
doc.Strings.SetString("수정내용", (prev + " | " if prev else "") + "footing: B5 z2100, B6/B8 z150, B1 z2072.5, B2/B4 z177 (B2 legs end 2072.5), C-1 R for B1,B2,B3,B7,B10; B9 untouched")
|
|
res["objects_after"] = doc.Objects.Count
|
|
res["saved"] = bool(doc.WriteFile(DST, Rhino.FileIO.FileWriteOptions()))
|
|
res["out"] = DST
|
|
doc.Dispose()
|
|
except Exception:
|
|
res["error"] = traceback.format_exc()
|
|
res["done"] = True
|
|
json.dump(res, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1)
|