engineering/mech/draw.py is the only module in the package that touches a backend: it turns the pure engine's primitive descriptions into entity_create_* and dimension_* calls, places them in WCS, and writes the part model back onto the drawing as ACADMCP_MECH XDATA on an anchor POINT. It is not a contract member and neither are the tools - exactly like gear_draw_* and titleblock_apply_iso_a3, it composes the generic members, so it is written once and works on both engines by construction and no capability key is needed. No new ActiveX call was written, so there was nothing to probe on the live seat; measured instead that every one of the 23 backend members draw.py calls exists on ComBackend and that ComBackend has no abstract methods left. mech_part_draw takes one model - a turned profile or a plate outline plus typed features - and draws its views in first-angle positions (third on request), dimensions them and records the placement. mech_view_add reads the model back out of the drawing and adds a side, top, section (full/half/offset/revolved) or detail view months later without the caller re-describing the part. mech_dimension_part lays out ISO 129 dimensions with no overlapping text, resolves ISO 286 fits against the measured nominal, and moves the holes into a table past a threshold. mech_hole_pattern exposes the same expansion for a drawing that was never built from the model - with its own diameter guard, because Hole.validate needs a part and a standalone pattern has none. mech_part_inspect reads the payload back and never modifies the drawing. mech_part_from_spec draws a whole sheet inside one transaction. Every part is validated before the transaction opens, so a refusal leaves the drawing untouched and names the path (parts[1]: segments[0].d_outer: ...), and the rollback is shielded with the shape engineering/pid/spec.py documents: anyio cancellation is level-triggered, so a bare await in the handler would be cancelled before the rollback body ran and leave half a sheet inside an open transaction. fits goes through dimension_intents(fits=...), the API Task 6 shipped, rather than being stamped on at draw time: that is the path that validates a key by name and refuses a fit on a reference dimension or on a hole that moved into the table. It is scoped per view first - a fit on segment[0] names nothing in the end view, and refusing there would make a correct three-view sheet undrawable - and any key no view claimed is handed back to dimension_intents so the refusal is written in its own vocabulary. SECTION 21 registers the six tools in the new mech pack, with alias records (SECTIONPLANE, ARRAY plus shop-floor synonyms in English and Turkish - mil, kademeli mil, kama, pah, kesit, gorunus), a regenerated tool inventory, the README release snapshot at 210 tools in 24 groups, and the frozen group-size snapshot gaining mech: 6. Lean is deliberately untouched here: spec section 11 puts three of these on the lean surface together with group G's two sheet tools, and Task 15 makes that edit once across all four branches. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
214 lines
3.6 KiB
Python
214 lines
3.6 KiB
Python
"""The mechanical part model, view engine and standards tables.
|
|
|
|
Merge rule for the four track-B/G branches: the re-exports below are additive
|
|
and alphabetical — keep every side's names.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from .dimension import (
|
|
DIM_STYLES,
|
|
REFERENCE_FORMAT,
|
|
TEXT_WIDTH_FACTOR,
|
|
TOL_KEYS,
|
|
dimension_intents,
|
|
hole_table_rows,
|
|
intent_text,
|
|
is_reference,
|
|
layout_dimensions,
|
|
measured_value,
|
|
redundant_linear,
|
|
resolve_tolerance,
|
|
segment_key,
|
|
text_rects,
|
|
)
|
|
from .draw import (
|
|
ANCHOR_LAYER,
|
|
add_view,
|
|
dimension_part,
|
|
draw_from_spec,
|
|
draw_hole_pattern,
|
|
draw_part,
|
|
draw_prims,
|
|
read_part,
|
|
)
|
|
from .features import (
|
|
FEATURE_KINDS,
|
|
AxialBore,
|
|
BendLine,
|
|
CentreHole,
|
|
Chamfer,
|
|
CornerChamfer,
|
|
CornerFillet,
|
|
CrossHole,
|
|
Feature,
|
|
Fillet,
|
|
GearTeeth,
|
|
Hole,
|
|
HoleCircle,
|
|
HolePattern,
|
|
Keyway,
|
|
ORingGroove,
|
|
Pocket,
|
|
RetainingGroove,
|
|
Slot,
|
|
Thread,
|
|
Undercut,
|
|
feature_from_dict,
|
|
mirror_about_x,
|
|
)
|
|
from .part import (
|
|
PART_KINDS,
|
|
PrismaticPart,
|
|
RevolvedPart,
|
|
Segment,
|
|
build_part,
|
|
inner_radius_at,
|
|
outer_radius_at,
|
|
outline_bbox,
|
|
part_length,
|
|
part_max_diameter,
|
|
part_to_dict,
|
|
point_in_outline,
|
|
segment_bounds,
|
|
validate_part,
|
|
)
|
|
from .primitives import (
|
|
ROLE_LAYER,
|
|
ROLES,
|
|
Arc,
|
|
Circle,
|
|
DimIntent,
|
|
HatchArea,
|
|
Line,
|
|
Poly,
|
|
Prim,
|
|
Pt,
|
|
Role,
|
|
Text,
|
|
bbox,
|
|
layer_for,
|
|
points_of,
|
|
rotate,
|
|
scale,
|
|
translate,
|
|
)
|
|
from .views import (
|
|
CIRCLE_SEGMENTS,
|
|
PROJECTIONS,
|
|
SECTION_PLANE,
|
|
SECTION_STYLES,
|
|
VIEW_KINDS,
|
|
Band,
|
|
View,
|
|
build_view,
|
|
cut_loops,
|
|
detail_marker_prims,
|
|
detail_view,
|
|
layout_origin,
|
|
normalise_plane,
|
|
outline_prims,
|
|
radial_profile,
|
|
section_profile_prims,
|
|
section_view,
|
|
silhouette_prims,
|
|
)
|
|
|
|
__all__ = [
|
|
"ANCHOR_LAYER",
|
|
"Arc",
|
|
"AxialBore",
|
|
"Band",
|
|
"BendLine",
|
|
"CIRCLE_SEGMENTS",
|
|
"CentreHole",
|
|
"Chamfer",
|
|
"Circle",
|
|
"CornerChamfer",
|
|
"CornerFillet",
|
|
"CrossHole",
|
|
"DIM_STYLES",
|
|
"DimIntent",
|
|
"FEATURE_KINDS",
|
|
"Feature",
|
|
"Fillet",
|
|
"GearTeeth",
|
|
"HatchArea",
|
|
"Hole",
|
|
"HoleCircle",
|
|
"HolePattern",
|
|
"Keyway",
|
|
"Line",
|
|
"ORingGroove",
|
|
"PART_KINDS",
|
|
"PROJECTIONS",
|
|
"Pocket",
|
|
"Poly",
|
|
"Prim",
|
|
"PrismaticPart",
|
|
"Pt",
|
|
"REFERENCE_FORMAT",
|
|
"ROLES",
|
|
"ROLE_LAYER",
|
|
"RetainingGroove",
|
|
"RevolvedPart",
|
|
"Role",
|
|
"SECTION_PLANE",
|
|
"SECTION_STYLES",
|
|
"Segment",
|
|
"Slot",
|
|
"TEXT_WIDTH_FACTOR",
|
|
"TOL_KEYS",
|
|
"Text",
|
|
"Thread",
|
|
"Undercut",
|
|
"VIEW_KINDS",
|
|
"View",
|
|
"add_view",
|
|
"bbox",
|
|
"build_part",
|
|
"build_view",
|
|
"cut_loops",
|
|
"detail_marker_prims",
|
|
"detail_view",
|
|
"dimension_intents",
|
|
"dimension_part",
|
|
"draw_from_spec",
|
|
"draw_hole_pattern",
|
|
"draw_part",
|
|
"draw_prims",
|
|
"feature_from_dict",
|
|
"hole_table_rows",
|
|
"inner_radius_at",
|
|
"intent_text",
|
|
"is_reference",
|
|
"layer_for",
|
|
"layout_dimensions",
|
|
"layout_origin",
|
|
"measured_value",
|
|
"mirror_about_x",
|
|
"normalise_plane",
|
|
"outer_radius_at",
|
|
"outline_bbox",
|
|
"outline_prims",
|
|
"part_length",
|
|
"part_max_diameter",
|
|
"part_to_dict",
|
|
"point_in_outline",
|
|
"points_of",
|
|
"radial_profile",
|
|
"read_part",
|
|
"redundant_linear",
|
|
"resolve_tolerance",
|
|
"rotate",
|
|
"scale",
|
|
"section_profile_prims",
|
|
"section_view",
|
|
"segment_bounds",
|
|
"segment_key",
|
|
"silhouette_prims",
|
|
"text_rects",
|
|
"translate",
|
|
"validate_part",
|
|
]
|