Files
autocad-mcp-pro/engineering/mech/__init__.py
T
Umut CANandClaude Opus 5 72bd17d024 feat(task-5): sections, cut faces, material hatch and detail views
engineering/mech/views.py grows the two remaining view kinds. A section's cut
faces come out of the same radial profile the silhouette does, so the hatched
area and the drawn outline are one calculation and cannot disagree: a solid
shaft's half-section loop measures exactly the sum of its segment rectangles,
and a bore closes the loop on itself rather than being hatched over.

ISO 6410's section convention falls out of the model rather than being special-
cased: an internal thread's radial_edit already raises the bore to the major
diameter, so the hatch stops there. ISO 128-3's rib rule is a flag on the
feature - a pocket marked no_section_hatch is drawn and left unhatched, while
the rest of the cut face is hatched with the part's ISO 128-50 material.

Four styles, each either implemented or refused by name with the alternative
rather than approximated: full and half on a longitudinal plane through a
revolved axis; full and revolved on a transverse plane (the annulus, flattened
at 2 degrees - 0.015% of the radius, stated in CIRCLE_SEGMENTS rather than
hidden); full and offset on a prismatic part, where through features split the
cut face and pockets reduce it to the remaining thickness. A plane that misses
the part, or that grazes an outline vertex so its crossings cannot be paired, is
refused instead of producing a guessed cut face.

Details scale a circular region of a parent view, emit the ISO 128-34 circle and
letter for the parent and the "A (5:1)" label for the detail itself, and report
every feature that falls outside the circle in omitted - the honesty rule again.

Three test assertions were corrected to the measured truth rather than the
engine bent to them, each verified by running the code:

* the ISO 6410 test asked for the whole cut-face loop's minimum to be the M20
  major (r=10). It is not, and must not be: over the 5 mm that is drilled but
  not threaded the loop closes on the real 16 mm drill (r=8). The loop is
  ((0,10),(0,25),(25,25),(30,25),(30,8),(30,8),(25,8),(25,10),(0,10)). The test
  now pins both spans, which is the convention it meant to assert.
* the transverse-annulus areas were pinned at rel=2e-4. An inscribed regular
  180-gon is exactly 1 - (n/2pi) sin(2pi/n) = 2.0307e-4 under the circle, so
  2e-4 rejects the very flattening CIRCLE_SEGMENTS declares. The tolerance is
  now 2.1e-4 and the test computes the deficit and pins it, so the number is
  derived rather than guessed. CIRCLE_SEGMENTS' docstring now states both
  figures: 0.015% radial (the 2 degree chord's sagitta) and 0.0203% of area.
* tests/test_mech_views.py pinned VIEW_KINDS == ("front","side","top"), which
  this task deliberately grows. It now pins the three orthographic kinds as the
  first three and the full five-kind tuple.

_is_longitudinal takes only the plane; the plan's signature also took the part
and never read it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01FKFStjEFzpGyLq5bMpWxTd
2026-09-22 21:40:29 +03:00

164 lines
2.7 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 .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_view,
silhouette_prims,
)
__all__ = [
"Arc",
"AxialBore",
"Band",
"BendLine",
"CIRCLE_SEGMENTS",
"CentreHole",
"Chamfer",
"Circle",
"CornerChamfer",
"CornerFillet",
"CrossHole",
"DimIntent",
"FEATURE_KINDS",
"Feature",
"Fillet",
"GearTeeth",
"HatchArea",
"Hole",
"HoleCircle",
"HolePattern",
"Keyway",
"Line",
"ORingGroove",
"PART_KINDS",
"PROJECTIONS",
"Pocket",
"Poly",
"Prim",
"PrismaticPart",
"Pt",
"ROLES",
"ROLE_LAYER",
"RetainingGroove",
"RevolvedPart",
"Role",
"SECTION_PLANE",
"SECTION_STYLES",
"Segment",
"Slot",
"Text",
"Thread",
"Undercut",
"VIEW_KINDS",
"View",
"bbox",
"build_part",
"build_view",
"cut_loops",
"detail_marker_prims",
"detail_view",
"feature_from_dict",
"inner_radius_at",
"layer_for",
"layout_origin",
"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",
"rotate",
"scale",
"section_view",
"segment_bounds",
"silhouette_prims",
"translate",
"validate_part",
]