Files
Pier_v1/Code/검토수정/스크립트/c1_layers_on.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

56 lines
2.3 KiB
Python

#! python3
# make layer visibility of each modified model equal to its reviewed (검토완료) model, so rebar is visible on open
# a file locked by another Rhino window is skipped and reported (not overwritten)
import os, json, traceback
import Rhino
BASE = r"D:\★Pier 자료\프로그램\Pier_T\검토파일"
PAIRS = [
("철근 모델랑 운곡교P1_바이브코딩", "운곡교p1_검토완료.3dm", "운곡교p1_수정2_20261023.3dm"),
("검토_산외교P1", "산외교P1 G5_검토완료.3dm", "산외교P1 G5_수정_20261023.3dm"),
("검토_옥성교P1", "옥성교P1_G5_검토완료.3dm", "옥성교P1_G5_수정_20261023.3dm"),
("Ramp-A교P1", "ramp-A G5_검토완료.3dm", "ramp-A G5_수정_20261023.3dm"),
]
OUT = r"C:\Users\User\AppData\Local\PierApp\jobs\c1_work\c1_layers_on.json"
res = {}
def fix_one(folder, rev, mod):
rdoc = Rhino.RhinoDoc.OpenHeadless(os.path.join(BASE, folder, rev))
want = {l.FullPath: l.IsVisible for l in rdoc.Layers}
rdoc.Dispose()
p = os.path.join(BASE, folder, mod)
doc = Rhino.RhinoDoc.OpenHeadless(p)
changed = []
for l in list(doc.Layers):
if l.IsDeleted:
continue
if want.get(l.FullPath) and not l.IsVisible:
doc.Layers.ForceLayerVisible(l.Index)
changed.append(l.FullPath)
still_off = [l.FullPath for l in doc.Layers if (not l.IsDeleted) and want.get(l.FullPath) and not l.IsVisible]
n_off = sum(1 for l in doc.Layers if (not l.IsDeleted) and not l.IsVisible)
objs = doc.Objects.Count
tmp = p + ".tmp.3dm"
ok = bool(doc.WriteFile(tmp, Rhino.FileIO.FileWriteOptions()))
doc.Dispose()
r = {"layers_turned_on": len(changed), "still_off_that_reviewed_shows": still_off, "layers_off_now": n_off, "objects": objs, "written": ok}
if ok:
try:
os.replace(tmp, p)
r["saved"] = True
except PermissionError:
r["saved"] = False
r["error"] = "file is locked (open in another Rhino window) - not overwritten"
os.remove(tmp)
return r
for folder, rev, mod in PAIRS:
try:
res[mod] = fix_one(folder, rev, mod)
except Exception:
res[mod] = {"saved": False, "error": traceback.format_exc()}
res["done"] = True
json.dump(res, open(OUT, "w", encoding="utf-8"), ensure_ascii=False, indent=1)