The four track-B/G branches are merged; this is the integration that makes the 25 new tools one surface instead of four. - engineering/mech/critique.py: the six focuses of spec 13, dispatched the way the P&ID ones are. One index per critique run, shared through run_critique's context, so six focuses cost one read of the drawing; a drawing with no ACADMCP_MECH payload yields nothing at all, which is what keeps focus=None cheap for a P&ID sheet or a plain DXF. Each focus has a positive and a negative fixture. Two narrowings are in the module docstring rather than hidden: mech_view_misaligned checks the projection axis and not the quadrant, because the pinned payload carries no projection angle to check it against, and mech_duplicate_dimension catches two dimensions in the same place rather than a semantic restatement, because no engine exposes what a dimension measured. - The index reads what the tools actually write, not only the plan's fixture shape. mech_part_draw anchors its part payload on a POINT (layer MECH) and lists every drawn view under "views"; the plan's index read INSERT/CIRCLE only and one "view" per payload, so it was silent on every part the server draws. It now reads POINT too, expands "views" into one entry per drawn view (the section check looks in the section's own WCS box, the alignment check compares frame_bbox centres), and pages entity_list instead of one call. Test: a part drawn by draw_part + add_view is read and passes all six; the same part with its hatch erased is reported. - Live type names, measured on AutoCAD 2026 (2026-09-23, scratch document, closed): ObjectName AcDbBlockReference -> BLOCKREFERENCE, AcDbRotatedDimension -> ROTATEDDIMENSION, AcDbAlignedDimension -> ALIGNEDDIMENSION, AcDbPoint -> POINT with GetBoundingBox = the point. The index reads BLOCKREFERENCE as an INSERT and any *DIMENSION as a dimension; a wrapper test reports the ezdxf entities under exactly those measured names. - mech_thread_unrepresented uses the view engine's own MINOR_RATIO, and checks the thin line ISO 6410 draws: the minor diameter of an external thread, the major of an internal one. - mech_bom_balloon_mismatch: identical parts share one balloon (ISO 6433 balloons a parts-list row), so a second M12x60 is covered by the first one's balloon instead of reported. - TOOL_PACK_NAMES has "mech" (the 14 tools of SECTIONS 21-23). SECTION 24 stays core: a frame, a title block, a parts list and an xref are universal drafting, not a vertical. Lean gains five and reaches 60 (54 with TOOL_PACKS=core). - _GROUP_TAG_PRIORITY gains sheet directly after mech; the mech group label becomes "mechanical". SECTION 24's last four tools (xref_attach, xref_manage, image_attach, drawing_export_dwg) now carry the sheet tag, so group, pack and SECTION are one list: 229 tools in 25 groups, and engineering/blocks/entity_creation/drawing return to their pre-SECTION-24 sizes. - Ten golden tuning cases, two of them Turkish (with the diacritic spellings added to the alias records next to the ASCII-folded ones). The shared AutoCAD command set needed no change: the merge had already resolved TABLE, REVCLOUD, SECTIONPLANE, INSERT, ARRAY and SAVEAS, and nothing is stale. - Inventory regenerated, the frozen group-size snapshot retaken from the live registry, and the README release-snapshot / pack / lean figures taken from scripts/check_doc_numbers.py rather than typed. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
128 lines
3.4 KiB
Python
128 lines
3.4 KiB
Python
"""Premium drawing planning + critique data models.
|
|
|
|
PlanSpec is committed up-front by the LLM via `drawing_plan(...)` before any
|
|
geometry is created; CritiqueFocus is a closed enum to keep
|
|
`drawing_critique(...)` scope from drifting.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Literal
|
|
|
|
SheetSize = Literal["A4", "A3", "A2", "A1", "A0"]
|
|
LayerSetId = Literal["iso13567", "mech", "pid"]
|
|
DimStyle = Literal["chain", "baseline", "ordinate", "mixed"]
|
|
CritiqueFocus = Literal[
|
|
"iso128",
|
|
"layer_color",
|
|
"dim_overlap",
|
|
"untrimmed_corner",
|
|
"duplicate_entities",
|
|
"construction_left",
|
|
"gdt",
|
|
"pid_dangling_line",
|
|
"pid_duplicate_tag",
|
|
"pid_incompatible_connection",
|
|
"pid_untagged_instrument",
|
|
"pid_illegal_tag",
|
|
"pid_unconnected_equipment",
|
|
"mech_missing_centreline",
|
|
"mech_unhatched_section",
|
|
"mech_view_misaligned",
|
|
"mech_duplicate_dimension",
|
|
"mech_thread_unrepresented",
|
|
"mech_bom_balloon_mismatch",
|
|
]
|
|
SnapType = Literal["end", "mid", "center", "quad", "int", "perp", "near"]
|
|
|
|
ALL_CRITIQUE_FOCUSES: tuple[CritiqueFocus, ...] = (
|
|
"iso128",
|
|
"layer_color",
|
|
"dim_overlap",
|
|
"untrimmed_corner",
|
|
"duplicate_entities",
|
|
"construction_left",
|
|
"gdt",
|
|
"pid_dangling_line",
|
|
"pid_duplicate_tag",
|
|
"pid_incompatible_connection",
|
|
"pid_untagged_instrument",
|
|
"pid_illegal_tag",
|
|
"pid_unconnected_equipment",
|
|
"mech_missing_centreline",
|
|
"mech_unhatched_section",
|
|
"mech_view_misaligned",
|
|
"mech_duplicate_dimension",
|
|
"mech_thread_unrepresented",
|
|
"mech_bom_balloon_mismatch",
|
|
)
|
|
|
|
|
|
@dataclass
|
|
class PlanSpec:
|
|
"""Drawing intent committed before geometry creation.
|
|
|
|
Returned by `drawing_plan(...)` and replayed by `drawing_critique(...)` to
|
|
verify the finished drawing matches the original intent.
|
|
"""
|
|
|
|
intent: str
|
|
sheet_size: SheetSize
|
|
scale: float
|
|
layer_set_id: LayerSetId
|
|
view_count: int = 1
|
|
dim_style: DimStyle = "chain"
|
|
notes: list[str] = field(default_factory=list)
|
|
requirements: dict = field(default_factory=dict)
|
|
spec_hash: str | None = None
|
|
preflight_status: Literal["ready", "skipped"] = "skipped"
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"intent": self.intent,
|
|
"sheet_size": self.sheet_size,
|
|
"scale": self.scale,
|
|
"layer_set_id": self.layer_set_id,
|
|
"view_count": self.view_count,
|
|
"dim_style": self.dim_style,
|
|
"notes": list(self.notes),
|
|
"requirements": dict(self.requirements),
|
|
"spec_hash": self.spec_hash,
|
|
"preflight_status": self.preflight_status,
|
|
}
|
|
|
|
|
|
@dataclass
|
|
class Issue:
|
|
"""One problem reported by `drawing_critique(...)`."""
|
|
|
|
severity: Literal["error", "warning", "info"]
|
|
focus: CritiqueFocus
|
|
message: str
|
|
handles: list[str] = field(default_factory=list)
|
|
detail: dict = field(default_factory=dict)
|
|
|
|
def to_dict(self) -> dict:
|
|
return {
|
|
"severity": self.severity,
|
|
"focus": self.focus,
|
|
"message": self.message,
|
|
"handles": list(self.handles),
|
|
"detail": self.detail,
|
|
}
|
|
|
|
|
|
# ISO 128 lineweight set (mm). Any lineweight outside this set is flagged.
|
|
ISO_128_LINEWEIGHTS_MM: tuple[float, ...] = (
|
|
0.13,
|
|
0.18,
|
|
0.25,
|
|
0.35,
|
|
0.50,
|
|
0.70,
|
|
1.00,
|
|
1.40,
|
|
2.00,
|
|
)
|