- 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>
127 lines
5.7 KiB
Python
127 lines
5.7 KiB
Python
#! python3
|
|
# Ramp-A P3-2 (H16, 30 bars): rebuild as a plain U (ㄷ) bar: horizontal bottom, vertical legs, corner R24 (KDS H16 minimum, drawing has none),
|
|
# leg length so that sum of straight dimensions W + 2h = material-table L 3,342. Leg positions / plane / bottom EL kept from the model.
|
|
# Source: ramp-A G5_수정3_20261026.3dm -> ramp-A G5_수정4_20261026.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 Arc, ArcCurve, LineCurve, PolyCurve, Point3d, Vector3d, Brep, PipeCapMode
|
|
from c1_core import BASE, required_rc
|
|
|
|
DATE_TXT = "2026-10-26"
|
|
SRC = os.path.join(BASE, "Ramp-A교P1", "ramp-A G5_수정3_20261026.3dm")
|
|
DST = os.path.join(BASE, "Ramp-A교P1", "ramp-A G5_수정4_20261026.3dm")
|
|
OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_p32_fix.json"
|
|
R = 24.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 = Rhino.Geometry.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 build_u(c, zb_expected_tol=0.6):
|
|
n = c.SegmentCount
|
|
s0, sN = c.SegmentCurve(0), c.SegmentCurve(n - 1)
|
|
T1, T2 = s0.PointAtStart, sN.PointAtEnd # leg top ends (plan positions of both legs)
|
|
zb = c.GetBoundingBox(True).Min.Z # bottom centre-line height
|
|
u = Vector3d(T2.X - T1.X, T2.Y - T1.Y, 0.0)
|
|
W = u.Length
|
|
u.Unitize()
|
|
Ltab = None
|
|
return T1, T2, zb, u, W
|
|
|
|
|
|
def make_u(T1, T2, zb, u, W, Ltab, r):
|
|
h = (Ltab - W) / 2.0 # sum of straight dimensions W + 2h = L
|
|
zt = zb + h
|
|
C1 = Point3d(T1.X, T1.Y, zb)
|
|
C2 = Point3d(T2.X, T2.Y, zb)
|
|
up = Vector3d(0, 0, 1)
|
|
A = C1 + up * r # end of straight leg 1 / start of corner 1
|
|
B = C1 + u * r # end of corner 1 / start of bottom
|
|
Cc = C2 - u * r # end of bottom / start of corner 2
|
|
D = C2 + up * r # end of corner 2 / start of leg 2
|
|
segs = [LineCurve(Point3d(T1.X, T1.Y, zt), A),
|
|
ArcCurve(Arc(A, -up, B)),
|
|
LineCurve(B, Cc),
|
|
ArcCurve(Arc(Cc, u, D)),
|
|
LineCurve(D, Point3d(T2.X, T2.Y, zt))]
|
|
pc = PolyCurve()
|
|
for s in segs:
|
|
pc.Append(s)
|
|
return pc, h
|
|
|
|
|
|
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
|
|
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, Rhino.Geometry.Curve) and "중심선" in L and o.Attributes.GetUserString("mark") == "P3-2":
|
|
curves.append(o)
|
|
stat = collections.Counter()
|
|
samples = []
|
|
req, d = required_rc("H16")
|
|
for o in curves:
|
|
a = o.Attributes
|
|
c = o.Geometry
|
|
nb = breps.get(a.Name.replace("-RC-", "-R-"), [])
|
|
if len(nb) != 1 or not isinstance(c, PolyCurve) or c.SegmentCount != 9:
|
|
stat["unexpected"] += 1
|
|
continue
|
|
T1, T2, zb, u, W = build_u(c)
|
|
Ltab = float(a.GetUserString("design_length"))
|
|
pc, h = make_u(T1, T2, zb, u, W, Ltab, R)
|
|
if h < 200.0:
|
|
stat["leg_shorter_than_weld_200"] += 1
|
|
continue
|
|
pipe = robust_pipe(pc, d, tol)
|
|
if pipe is None:
|
|
stat["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["replace_failed"] += 1
|
|
continue
|
|
for oid in (cid, bid):
|
|
ro = doc.Objects.FindId(oid)
|
|
at = ro.Attributes.Duplicate()
|
|
at.SetUserString("shape_fix", "plain U: bottom W %.1f, legs h %.1f vertical, corner R%.0f (KDS H16 min), L table %.0f (%s)" % (W, h, R, Ltab, DATE_TXT))
|
|
doc.Objects.ModifyAttributes(ro, at, True)
|
|
if len(samples) < 2:
|
|
bb = pc.GetBoundingBox(True)
|
|
samples.append({"name": a.Name, "old_len": round(c.GetLength(), 1), "new_len": round(pc.GetLength(), 1), "W": round(W, 1), "h": round(h, 1),
|
|
"z": [round(bb.Min.Z, 1), round(bb.Max.Z, 1)], "old_z": [round(c.GetBoundingBox(True).Min.Z, 1), round(c.GetBoundingBox(True).Max.Z, 1)]})
|
|
stat["done"] += 1
|
|
res["stat"] = dict(stat)
|
|
res["samples"] = samples
|
|
doc.Strings.SetString("수정일", DATE_TXT)
|
|
prev = doc.Strings.GetValue("수정내역") or ""
|
|
prev = doc.Strings.GetValue("수정내용") or ""
|
|
doc.Strings.SetString("수정내용", (prev + " | " if prev else "") + "P3-2 rebuilt as plain U (legs vertical, R24, L 3342)")
|
|
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)
|