feat(styles): drawing_apply_standard — ISO or ANSI styles, units and layers in one idempotent call

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
This commit is contained in:
Umut CAN
2026-09-21 22:49:12 +03:00
co-authored by Claude Opus 5
parent 021a4eb43d
commit a5d166f365
7 changed files with 269 additions and 10 deletions
+37 -1
View File
@@ -6818,7 +6818,7 @@ async def pid_tag_parse(
# ---------------------------------------------------------------------------
# ── SECTION 18: Styles (9 tools) ────────────────────────────────────────────
# ── SECTION 18: Styles (10 tools) ───────────────────────────────────────────
# ---------------------------------------------------------------------------
#
# Pack: core (drafting essentials). Lean profile: dimstyle_set_current and
@@ -7076,6 +7076,42 @@ async def mleaderstyle_create(
return await _backend(ctx).mleaderstyle_create(name, values)
@cad_tool(
summary="Put the drawing on ISO or ANSI in one call: dimstyle, text style, units, mech layers.",
cost="mutate",
)
@mcp.tool(
annotations={"title": "Drawing: Apply Drafting Standard", "readOnlyHint": False},
tags={"style", "drawing"},
)
async def drawing_apply_standard(
standard: Annotated[
str, "iso (ISO-25 / ISOCP, decimal comma) | ansi (ANSI / ROMANS, decimal point)"
],
layers: Annotated[bool, "Also bootstrap the mech layer set with ISO 128 lineweights"] = True,
units: Annotated[
bool, "Also write INSUNITS mm, LUNITS/AUNITS decimal, LTSCALE 1, DIMSCALE 1"
] = True,
ctx: Context = None,
) -> dict:
"""One call for the common case: the standard's dimension style (created
if missing, then current), its text style (created if missing, then
current), the shared units, and with `layers` the `mech` layer set (ANSI
layer naming is company-specific, so both standards share it).
Every item reports `created` or already present; `settings.changed`
names only the variables that moved, so a second call reports nothing.
An existing ISO-25 / ANSI style is reused as it is, not reset — use
`dimstyle_modify` to change one. Refuses an unknown standard before any
write; the underlying style refusals (`dimstyle_create`,
`textstyle_create`) apply unchanged. In the `lean` profile (Task 13).
"""
from engineering.standards.apply import apply_standard
await ctx.info(f"Applying the {standard} drafting standard")
return await apply_standard(_backend(ctx), standard, layers, units)
# ---------------------------------------------------------------------------
# ── RESOURCES ───────────────────────────────────────────────────────────────
# ---------------------------------------------------------------------------