Dimension Analysis#

The dimension analysis module provides advanced tools for analyzing dimensions in technical drawings and extracting their relationships with geometric entities.

Purpose#

Dimensions in technical drawings do more than display measurements - they define relationships between geometric elements. This module provides:

  • Constraint Point Detection: Identifies the geometric points that a dimension constrains

  • Geometry-Dimension Mapping: Links dimensions to their referenced geometries

  • Metadata Extraction: Extracts additional information from dimension annotations

  • Dimension Classification: Categorizes dimensions by type (linear, angular, radial, etc.)

These capabilities are useful for:

  • Understanding which geometries are constrained by dimensions

  • Validating dimension coverage

  • Extracting structured measurement data

  • Automated design verification

Note

Constraint point extraction and dimension classification are not documented in detail yet. Please refer to the API Reference for available classes and methods in the drawing_tools.view.annotations.dimensioning module.

Working examples: scripts/dimensions.py for the section below, scripts/view_graph.py for the constraint graph.

The three positions of a dimension end#

A drawing standard leaves a gap between an extension line and the feature it measures, so the point an export gives is never on that feature. At a single end of a dimension, three distinct positions therefore exist, and they must not be confused:

arrow tip                 on the dimension line
extension line end        where the export stops the line     <- what the export gives
measured point            on the geometry                     <- what the end measures

get_dimension_ends() returns one DimensionEnd per end, carrying all three plus the edge the measured point was found on and the gap that was crossed:

analyzer = DimensionAnalyzer(view)
for dimension_end in analyzer.get_dimension_ends(dimension):
    dimension_end.measured_point     # on the geometry
    dimension_end.measured_edge      # the edge it was found on
    dimension_end.measured_gap       # how far it sat from the extension line end

The measured point is found by sweeping a SearchCorridor along the extension line rather than searching a radius around its end, and the first edge met wins. Its two sizes are arguments of the analyzer:

DimensionAnalyzer(view, corridor_length=2.0, corridor_width=0.2)

corridor_length is a maximum reach, never a step: the gap varies from one end to the next – 0.00, 0.47, 0.80, 1.07, 1.20, 1.28, 1.54 and 2.00 over the reference drawings – so advancing by a fixed amount would overshoot wherever the drawing left no gap.

corridor_width is the corridor’s total width, half of it either side of the extension line’s prolongation, so the default of 0.2 tolerates a feature 0.1 off that line. It is what admits a feature the drawing placed slightly off the line while leaving a neighbouring one out.

Three criteria rank what the corridor reaches, in this order: how far off its axis the point sits, then how far into the corridor it was reached, then – where the drawing left no gap and several edges touch the very same spot with the first two exactly equal – how closely each edge runs along the corridor, an extension line being the prolongation of the feature it measures.

Only the kinds listed in SEARCHED_DIMENSION_TYPES are searched – DistanceDimension, LengthDimension and LinearDimension – because a radius or diameter arrow already touches its arc. On every other kind, and on any end whose search reaches nothing, measured_point falls back to the extension line end; was_searched and reached_geometry tell those two cases apart, and measured_gap is None rather than a fabricated 0.00.

Warning

get_dimension_geometry_constraint_points() does not return points on the geometry despite its name. It searches at the analyzer’s numerical precision, three orders of magnitude below the gap, and falls back to the extension line end – which is every time on the reference drawings. Use get_dimension_ends instead.

Visualization#

Dimension, tolerance, and roughness annotations can be visualized using dedicated @plot_data_view methods available on FeaturedView, FeaturedSheet, and FeaturedDrawing:

# Dimension overlays (colored labels per dimension)
featured_view.plot_data_dimensions().plot()
featured_sheet.plot_data_dimensions().plot()
featured_drawing.plot_data_dimensions().plot()

# Geometrical tolerance overlays (green outlines)
featured_view.plot_data_geometrical_tolerances().plot()
featured_sheet.plot_data_geometrical_tolerances().plot()
featured_drawing.plot_data_geometrical_tolerances().plot()

# Surface roughness overlays (blue outlines)
featured_view.plot_data_roughness().plot()
featured_sheet.plot_data_roughness().plot()
featured_drawing.plot_data_roughness().plot()

See Display & Report Methods for interactive examples on the GICLEUR and LH SUPPORT ACCUMULATOR drawings.

The structured parsing of dimension texts (main value, prefix, tolerance kind) is provided by DimensionParser from dessia_drawing. GeometryDimensionGraph (see Graph-Based Analysis) attaches the parsed attributes to each dimension node and uses build_compact_dimension_label() to build the on-canvas label.