- 길: sangeun from-line · formula-check · copy · equation(셋) · block · labor copy · 프로젝트 양식 reset · apply · save-as · sources · drawing-import · drawing-fields · logic-lib machine-parts · logic-lib/auto - 본체: Calc.from_line · Formula.check_doc 외 셋 · Equation 읽기 · 미리 셈 · Equation_Full 파일 · Block 끊기 · 잇기 · 수식 탭 · Labor_Copy.preview · Router_Layers 가져오기 도우미 - 화면: Api_Fetch 래퍼 여덟 · sangeunFromLine - 시험: 죽은 길만 보던 796-2c · 796-2e 파일 지움 · 함수째 지움(715-3 · 733-2 · 792-1 · 796-2b · router_drawing · template_layers · structure_panel 글자 시험) · 살아 있는 결과는 [저장] 길로 고침(795-2 · 796-2b) · 813-2 = M01 parts.of_machine 바로 - 남김: Sangeun_Copy.preview(옛 엔진 셈 거울 — 걸음 2) · B07 이 쓰는 reset_project · B09 가 쓰는 _company_projects - 검증: /openapi.json 524 → 508(뜻한 16 만) · 빌더 --check 같음 · 핵심 시험 99 통과 · 관련 시험 687 통과 · typecheck 0 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
64 lines
2.4 KiB
Python
64 lines
2.4 KiB
Python
"""M02 구조물 도면에 얹는 도각 길(`/structure-frame` · 56장) — B07 시스템 양식 도각을 그대로 다시 쓴다.
|
|
|
|
양식을 읽고 쓰는 길은 `M02_MasterTemplete_Router.py`(시스템 층)·`_Router_Layers.py`(층)가 맡는다.
|
|
"""
|
|
|
|
from fastapi import APIRouter
|
|
from fastapi.responses import JSONResponse
|
|
|
|
from B07_DesignDetail.B07_DesignDetail_Engine_Template import (
|
|
entities_bbox,
|
|
frame_entities,
|
|
frame_guide_area,
|
|
usable_bbox,
|
|
)
|
|
|
|
router = APIRouter(prefix="/api/m02", tags=["M02 MasterTemplete"])
|
|
|
|
# 얹은 도각 층 — 화면이 돌려줄 때 이 층을 통째로 뺌 · 불러온 DXF 층(`b08-frame`)과 갈라 둠
|
|
STRUCTURE_FRAME_LAYER = "m02-structure-frame"
|
|
|
|
|
|
def _on_frame_layer(entity: dict) -> dict:
|
|
children = entity.get("children")
|
|
return {
|
|
**entity,
|
|
"layerId": STRUCTURE_FRAME_LAYER,
|
|
**({"children": [_on_frame_layer(c) for c in children]} if children else {}),
|
|
}
|
|
|
|
|
|
def structure_frame(number: str | None = None, name: str | None = None) -> dict:
|
|
"""구조물 도면에 얹는 도각 — B07 시스템 양식 1:1 · 외곽 좌하단 (0,0) · 보여주기 층 ·
|
|
`number` = 장 도번(82-2 · 도각 `{{도면번호}}`) · `name` = 도면명(376 · B07 구조물 도면)."""
|
|
fields = {
|
|
**({"도면번호": number} if number else {}),
|
|
**({"도면명": name} if name else {}),
|
|
} or None
|
|
placed = frame_entities("m02-structure", usable_bbox(), fit=False)
|
|
box = entities_bbox(placed)
|
|
if not box:
|
|
return {"entities": [], "layer": None}
|
|
ox, oy = box[0], box[1]
|
|
x0, y0, x1, y1 = usable_bbox()
|
|
entities = frame_entities(
|
|
"m02-structure", (x0 - ox, y0 - oy, x1 - ox, y1 - oy), fit=False, fields=fields
|
|
)
|
|
return {
|
|
"entities": [_on_frame_layer(entity) for entity in entities],
|
|
# 작도 영역(도각과 같은 좌표) — CAD 가이드 선(169-4 · 보기만)
|
|
"area": frame_guide_area(entities),
|
|
"layer": {
|
|
"id": STRUCTURE_FRAME_LAYER,
|
|
"name": "도각(보기)",
|
|
"isVisible": True,
|
|
"isLocked": True,
|
|
},
|
|
}
|
|
|
|
|
|
@router.get("/structure-frame")
|
|
async def get_structure_frame(number: str | None = None) -> JSONResponse:
|
|
"""구조물 도면 상세 · 카드 미리보기가 얹는 도각(56장) · `number` = 장 도번(82-2)."""
|
|
return JSONResponse({"status": "success", **structure_frame(number)})
|