- 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>
132 lines
5.9 KiB
Python
132 lines
5.9 KiB
Python
#! python3
|
|
# fix the straight length b of the hooked bars (drawing: b = leg line to the START of the hook arc):
|
|
# Okseong P5 (a160 b2341), Ramp-A P3 (a200 b1832), P3-1 (a200 b2137). The model measured b to the hook vertex (R24*tan67.5 = 57.9 short).
|
|
# Sources: Okseong ..._수정5 -> ..._수정6_20261026 ; Ramp-A ..._수정4 -> ..._수정5_20261026
|
|
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
|
|
import Rhino.Geometry as rg
|
|
from Rhino.Geometry import Point3d, Vector3d, PolyCurve, LineCurve, Brep, PipeCapMode, Transform
|
|
from Rhino.Geometry.Intersect import Intersection
|
|
from c1_core import BASE, required_rc
|
|
|
|
DATE_TXT = "2026-10-26"
|
|
OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_hook_b_fix.json"
|
|
JOBS = {
|
|
"okseong": {"src": os.path.join(BASE, "검토_옥성교P1", "옥성교P1_G5_수정5_20261026.3dm"),
|
|
"dst": os.path.join(BASE, "검토_옥성교P1", "옥성교P1_G5_수정6_20261026.3dm"),
|
|
"marks": {"P5": (160.0, 2341.0)}},
|
|
"rampa": {"src": os.path.join(BASE, "Ramp-A교P1", "ramp-A G5_수정4_20261026.3dm"),
|
|
"dst": os.path.join(BASE, "Ramp-A교P1", "ramp-A G5_수정5_20261026.3dm"),
|
|
"marks": {"P3": (200.0, 1832.0), "P3-1": (200.0, 2137.0)}},
|
|
}
|
|
res = {}
|
|
|
|
|
|
def robust_pipe(curve, d, tol):
|
|
for fit, atol in ((True, tol), (False, tol), (True, 0.01), (True, 0.1)):
|
|
rr = Brep.CreatePipe(curve, d / 2.0, False, PipeCapMode.Flat, fit, atol, Rhino.RhinoMath.ToRadians(1.0))
|
|
if rr and len(rr) == 1 and rr[0].IsSolid:
|
|
vol = rg.VolumeMassProperties.Compute(rr[0]).Volume
|
|
if abs(vol / (math.pi * (d / 2.0) ** 2 * curve.GetLength()) - 1.0) <= 0.005:
|
|
return rr[0]
|
|
return None
|
|
|
|
|
|
def measure(c):
|
|
"""a_model (leg end to vertex), b_model (vertex to start of hook arc) for the 5-segment bar"""
|
|
s0, s2, s3 = c.SegmentCurve(0), c.SegmentCurve(2), c.SegmentCurve(3)
|
|
l0 = rg.Line(s0.PointAtStart, s0.PointAtEnd)
|
|
l2 = rg.Line(s2.PointAtStart, s2.PointAtEnd)
|
|
ok, ta, tb = Intersection.LineLine(l0, l2)
|
|
V = l0.PointAt(ta) if ok else None
|
|
return V, s0.PointAtStart.DistanceTo(V), V.DistanceTo(s3.PointAtStart)
|
|
|
|
|
|
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
|
|
breps = collections.defaultdict(list)
|
|
curves = []
|
|
for o in doc.Objects.GetObjectList(st):
|
|
g = o.Geometry
|
|
L = lay.get(o.Attributes.LayerIndex, "")
|
|
if isinstance(g, Brep) and "철근" in L:
|
|
breps[o.Attributes.Name].append(o)
|
|
elif isinstance(g, rg.Curve) and "중심선" in L and o.Attributes.GetUserString("mark") in job["marks"]:
|
|
curves.append(o)
|
|
stat = collections.Counter()
|
|
sample = {}
|
|
for o in curves:
|
|
a = o.Attributes
|
|
m = a.GetUserString("mark")
|
|
a_dr, b_dr = job["marks"][m]
|
|
req, d = required_rc(a.GetUserString("dia"))
|
|
nb = breps.get(a.Name.replace("-RC-", "-R-"), [])
|
|
c = o.Geometry
|
|
if len(nb) != 1 or not isinstance(c, PolyCurve) or c.SegmentCount != 5:
|
|
stat[m + "_unexpected"] += 1
|
|
continue
|
|
V, a_m, b_m = measure(c)
|
|
if abs(a_m - a_dr) > 0.6:
|
|
stat[m + "_a_differs"] += 1
|
|
delta = b_dr - b_m
|
|
if abs(delta) < 0.05:
|
|
stat[m + "_already_ok"] += 1
|
|
continue
|
|
segs = [c.SegmentCurve(i).DuplicateCurve() for i in range(5)]
|
|
h = segs[2].PointAtEnd - segs[2].PointAtStart
|
|
h.Unitize()
|
|
mv = h * delta
|
|
newh = LineCurve(segs[2].PointAtStart, segs[2].PointAtEnd + mv)
|
|
for k in (3, 4):
|
|
segs[k].Transform(Transform.Translation(mv))
|
|
pc = PolyCurve()
|
|
pc.Append(segs[0]); pc.Append(segs[1]); pc.Append(newh); pc.Append(segs[3]); pc.Append(segs[4])
|
|
pipe = robust_pipe(pc, d, tol)
|
|
if pipe is None:
|
|
stat[m + "_pipe_fail"] += 1
|
|
continue
|
|
cid, bid = o.Id, nb[0].Id
|
|
if not (doc.Objects.Replace(cid, pc) and doc.Objects.Replace(bid, pipe)):
|
|
stat[m + "_replace_failed"] += 1
|
|
continue
|
|
for oid in (cid, bid):
|
|
ro = doc.Objects.FindId(oid)
|
|
at = ro.Attributes.Duplicate()
|
|
old = at.GetUserString("hook_fix") or ""
|
|
at.SetUserString("hook_fix", (old + " | " if old else "") + "b corrected %+.1f mm to drawing b %.0f (leg line to hook arc start) (%s)" % (delta, b_dr, DATE_TXT))
|
|
doc.Objects.ModifyAttributes(ro, at, True)
|
|
if m not in sample:
|
|
V2, a2, b2 = measure(pc)
|
|
sample[m] = {"a_before": round(a_m, 2), "b_before": round(b_m, 2), "delta": round(delta, 2), "a_after": round(a2, 2), "b_after": round(b2, 2),
|
|
"len_before": round(c.GetLength(), 1), "len_after": round(pc.GetLength(), 1),
|
|
"L_table_minus_bend": None}
|
|
stat[m + "_done"] += 1
|
|
r["stat"] = dict(stat)
|
|
r["sample"] = sample
|
|
doc.Strings.SetString("수정일", DATE_TXT)
|
|
prev = doc.Strings.GetValue("수정내용") or ""
|
|
doc.Strings.SetString("수정내용", (prev + " | " if prev else "") + "hook bars: b corrected to drawing (leg line to hook arc start)")
|
|
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)
|