- 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>
53 lines
1.8 KiB
Python
53 lines
1.8 KiB
Python
"""Render a rectangular region of a converted DXF to PNG (visual reading aid only).
|
|
|
|
usage: python render_region.py <drawing_index 1-3> <xmin> <ymin> <xmax> <ymax> <out_name> [px_width]
|
|
"""
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
import ezdxf
|
|
import matplotlib
|
|
|
|
matplotlib.use("Agg")
|
|
import matplotlib.pyplot as plt
|
|
from ezdxf.addons.drawing import Frontend, RenderContext
|
|
from ezdxf.addons.drawing.config import Configuration, BackgroundPolicy, ColorPolicy
|
|
from ezdxf.addons.drawing.matplotlib import MatplotlibBackend
|
|
|
|
HERE = Path(__file__).resolve().parent
|
|
|
|
|
|
def main():
|
|
idx, x0, y0, x1, y1 = int(sys.argv[1]), *map(float, sys.argv[2:6])
|
|
out = HERE / "판독" / f"{sys.argv[6]}.png"
|
|
width_px = int(sys.argv[7]) if len(sys.argv) > 7 else 2400
|
|
path = sorted((HERE / "입력DXF").glob("*.dxf"))[idx - 1]
|
|
doc = ezdxf.readfile(path)
|
|
msp = doc.modelspace()
|
|
# Only entities whose bounding box touches the region are drawn (speed).
|
|
from ezdxf import bbox
|
|
keep = []
|
|
for e in msp:
|
|
try:
|
|
b = bbox.extents([e], fast=True)
|
|
except Exception:
|
|
continue
|
|
if b.has_data and b.extmax.x >= x0 and b.extmin.x <= x1 and b.extmax.y >= y0 and b.extmin.y <= y1:
|
|
keep.append(e)
|
|
aspect = (y1 - y0) / (x1 - x0)
|
|
fig = plt.figure(figsize=(width_px / 100, width_px * aspect / 100), dpi=100)
|
|
ax = fig.add_axes([0, 0, 1, 1])
|
|
cfg = Configuration(background_policy=BackgroundPolicy.WHITE, color_policy=ColorPolicy.BLACK)
|
|
Frontend(RenderContext(doc), MatplotlibBackend(ax), config=cfg).draw_entities(keep)
|
|
ax.set_xlim(x0, x1)
|
|
ax.set_ylim(y0, y1)
|
|
ax.set_aspect("equal")
|
|
ax.axis("off")
|
|
fig.savefig(out, facecolor="white")
|
|
plt.close(fig)
|
|
print(out, len(keep))
|
|
|
|
|
|
if __name__ == "__main__":
|
|
main()
|