- 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>
92 lines
3.7 KiB
Python
92 lines
3.7 KiB
Python
"""Generic rebar stage (Ulsan P1 coping, 2026-10-13): bars given as explicit centreline polylines in params.
|
|
|
|
Run inside Rhino 8 via runner (globals PARAMS_PATH). Used as the G4 builder (params["coping_rebar"]).
|
|
params coping_rebar:
|
|
host object id suffix of the host concrete (e.g. "CP")
|
|
group layer group under 철근:: (e.g. "코핑")
|
|
bars [{mark, occ, pts [[x, y, z], ...], r (corner fillet radius), design_length, src}]
|
|
a closed bar repeats its first point at the end (start it mid-side so no corner sits at the seam)
|
|
Ids: <pier>-R-<mark>-<occ> (pipe) and <pier>-RC-<mark>-<occ> (centreline).
|
|
Section by gate (2026-10-14, Okseong P1): GATE "G3" -> params footing_rebar, otherwise coping_rebar.
|
|
"""
|
|
import json
|
|
import math
|
|
|
|
import Rhino
|
|
import Rhino.Geometry as rg
|
|
import System
|
|
from Rhino.DocObjects import ObjectAttributes
|
|
from System.Drawing import Color
|
|
|
|
P = json.load(open(PARAMS_PATH, encoding="utf-8"))
|
|
doc = __rhino_doc__
|
|
TOL = 0.01
|
|
PID = P["pier_id"]
|
|
SEC = P["footing_rebar" if globals().get("GATE") == "G3" else "coping_rebar"]
|
|
MARK = {m: (v["dia"], v["shape"]) for m, v in P["rebar_marks"].items()}
|
|
CL_RGB = tuple(P["display"]["centreline_colour"])
|
|
LAY_RGB = tuple(P["display"]["coping_layer_colour"])
|
|
|
|
|
|
def layer(path, color):
|
|
parent = -1
|
|
parts = path.split("::")
|
|
for i in range(1, len(parts) + 1):
|
|
idx = doc.Layers.FindByFullPath("::".join(parts[:i]), -1)
|
|
if idx < 0:
|
|
lay = Rhino.DocObjects.Layer()
|
|
lay.Name, lay.Color = parts[i - 1], Color.FromArgb(*color)
|
|
if parent >= 0:
|
|
lay.ParentLayerId = doc.Layers[parent].Id
|
|
idx = doc.Layers.Add(lay)
|
|
parent = idx
|
|
return parent
|
|
|
|
|
|
def centreline(pts, r):
|
|
pl = rg.PolylineCurve([rg.Point3d(*p) for p in pts])
|
|
if len(pts) < 3 or r <= 0:
|
|
return pl
|
|
c = rg.Curve.CreateFilletCornersCurve(pl, r, TOL, math.radians(1))
|
|
if c is None:
|
|
raise RuntimeError(f"fillet failed (r {r})")
|
|
return c
|
|
|
|
|
|
def add_bar(b):
|
|
mark, occ = b["mark"], b["occ"]
|
|
dia, shape = MARK[mark]
|
|
curve = centreline(b["pts"], b.get("r", 0))
|
|
pipes = rg.Brep.CreatePipe(curve, float(dia[1:]) / 2, False, rg.PipeCapMode.Flat, False, TOL, math.radians(1))
|
|
if not pipes or not pipes[0].IsSolid:
|
|
raise RuntimeError(f"{mark} {occ}: pipe failed")
|
|
common = dict(mark=mark, dia=dia, shape=shape, occurrence=occ, host=f"{PID}-{SEC['host']}", anchor_hosts="",
|
|
design_length=f"{b['design_length']:.3f}", coupler_length="0.000", src=b.get("src", ""))
|
|
for geo, lay, prefix in ((curve, layer(f"{PID}::철근::중심선", CL_RGB), f"{PID}-RC"),
|
|
(pipes[0], layer(f"{PID}::철근::{SEC['group']}::{mark}", LAY_RGB), f"{PID}-R")):
|
|
attr = ObjectAttributes()
|
|
attr.LayerIndex = lay
|
|
oid = f"{prefix}-{mark}-{occ}"
|
|
attr.Name = oid
|
|
attr.SetUserString("id", oid)
|
|
for k, v in common.items():
|
|
attr.SetUserString(k, v)
|
|
gid = doc.Objects.AddBrep(geo, attr) if isinstance(geo, rg.Brep) else doc.Objects.AddCurve(geo, attr)
|
|
if gid == System.Guid.Empty:
|
|
raise RuntimeError(f"{oid}: add failed")
|
|
|
|
|
|
def main():
|
|
marks = {b["mark"] for b in SEC["bars"]}
|
|
for o in list(doc.Objects):
|
|
oid = o.Attributes.GetUserString("id") or ""
|
|
if oid.startswith((f"{PID}-R-", f"{PID}-RC-")) and o.Attributes.GetUserString("mark") in marks:
|
|
doc.Objects.Delete(o, True)
|
|
for b in SEC["bars"]:
|
|
add_bar(b)
|
|
doc.Views.Redraw()
|
|
print(json.dumps({"bars": len(SEC["bars"]), "marks": len(marks)}))
|
|
|
|
|
|
main()
|