drawing_tools.view.annotations package#

Subpackages#

Submodules#

drawing_tools.view.annotations.dimension_analysis module#

View-based dimension analysis API for technical drawings.

class drawing_tools.view.annotations.dimension_analysis.ViewDimensionAnalysis(view: View, tolerance: float = 0.001)#

Bases: object

View-based dimension analysis for technical drawings.

Provides dimension constraint analysis, edge relationship detection, and geometric constraint extraction within a technical drawing view context.

__init__(view: View, tolerance: float = 0.001)#

Initialize the dimension analysis API with a view context.

Parameters:
  • view – The view containing dimensions and geometries

  • tolerance – Distance tolerance for point-to-edge matching

property analyzer: DimensionAnalyzer#

Get or create the dimension analyzer.

analyze_dimension(dimension: Dimension) → Constraint | None#

Analyze a dimension and return its constraint using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

Constraint or None if no relationships found

get_dimension_linked_edges(dimension: Dimension) → list[Edge]#

Get directly linked edges for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of directly linked edges

get_dimension_constrained_edges(dimension: Dimension) → list[Edge]#

Get directly constrained edges for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of directly constrained edges

analyze_all_dimensions() → list[Constraint]#

Analyze all dimensions in the view and return their constraints.

Returns:

List of all detected constraints

get_dimension_constraint_points(dimension: Dimension) → list#

Get constraint points for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of constraint points

get_dimension_constraint_points_with_metadata(dimension: Dimension) → list#

Get constraint points with metadata for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of DimensionConstraintPoint objects

drawing_tools.view.annotations.dimensioning module#

Dimension processors based on dimensions types.

class drawing_tools.view.annotations.dimensioning.BaseDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: object

Base class for dimension-specific constraint processors.

__init__(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Initialize the processor.

Parameters:
  • dimension – Dimension to process

  • point_mapper – PointToEdgeMapper instance for point-to-edge mapping

  • tolerance – Precision tolerance

  • distance_tolerance – Distance tolerance

  • dimension_analyzer – Required DimensionAnalyzer for constraint points

get_constraint_points() → list[Point2D]#

Return all points where the dimension constrains the geometry using smart analysis.

This method returns the actual geometry points that the dimension constrains, accounting for the typical 1-2mm offset between extension lines and geometry.

Returns:

List of actual geometry constraint points (Point2D objects)

get_constraint_points_with_metadata() → list#

Return constraint points with full metadata.

Returns:

List of DimensionConstraintPoint objects

to_constraint() → Constraint#

Translate the dimension into a Constraint.

Returns:

Constraint representing this dimension

get_directly_constrained_edges() → list[Edge]#

Return all direct constrained edges.

A directly constrained edge is an edge has at list on of its degree of freedom that is constrained by the dimension.

get_directly_linked_edges() → list[Edge]#

Return the directly linked edges to the dimension.

A directly linked edge is an edge whose on of it extremities is attached to the dimension by the extension lines. Or one of it features serves as reference to a dimension definition, line the center of a circle for a radius dimension.

class drawing_tools.view.annotations.dimensioning.LengthDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: BaseDimensionProcessor

Processor for LengthDimension types.

Inherits from BaseDimensionProcessor.

get_directly_constrained_edges() → list[Edge]#

Return all direct constrained edges.

A directly constrained edge is an edge has at list on of its degree of freedom that is constrained by the dimension.

to_constraint() → Constraint#

Translate the dimension into a constraint.

class drawing_tools.view.annotations.dimensioning.LinearDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: BaseDimensionProcessor

Processor for LinearDimension types.

Inherits from BaseDimensionProcessor.

to_constraint() → Constraint#

Translate the dimension into a constraint.

class drawing_tools.view.annotations.dimensioning.RadiusDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: BaseDimensionProcessor

Processor for RadiusDimension and LinearRadiusDimension types.

Inherits from BaseDimensionProcessor.

get_directly_constrained_edges() → list[Edge]#

Return all direct constrained edges for radius dimensions.

For radius dimensions, the constrained edge is the arc/circle that matches: 1. The leader arrow points to the center or on the arc 2. The radius matches the dimension value

to_constraint() → Constraint#

Translate the dimension into a constraint.

class drawing_tools.view.annotations.dimensioning.LinearRadiusDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: BaseDimensionProcessor

Processor for LinearRadiusDimension types (projected cylindrical features).

LinearRadiusDimension applies to line segments that represent the 2D projection of 3D cylindrical features. When a cylinder is viewed from the side, it appears as a rectangle, but the radius dimension still represents the original 3D radius.

Inherits from BaseDimensionProcessor.

to_constraint() → Constraint#

Translate the dimension into a constraint.

class drawing_tools.view.annotations.dimensioning.LinearDiameterDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: LinearRadiusDimensionProcessor

Processor for LinearDiameterDimension types (projected cylindrical features).

Similar to LinearRadiusDimension but the dimension value represents diameter.

Inherits from LinearRadiusDimensionProcessor.

to_constraint() → Constraint#

Translate the dimension into a constraint.

class drawing_tools.view.annotations.dimensioning.DiameterDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: RadiusDimensionProcessor

Processor for DiameterDimension and LinearDiameterDimension types.

Inherits from RadiusDimensionProcessor.

to_constraint() → Constraint#

Translate the dimension into a constraint.

class drawing_tools.view.annotations.dimensioning.AngularDimensionProcessor(dimension: Dimension, point_mapper: PointToEdgeMapper, dimension_analyzer: DimensionAnalyzer, tolerance: float = 0.001, distance_tolerance: float = 2)#

Bases: BaseDimensionProcessor

Processor for AngularDimension types with direction matching.

Inherits from BaseDimensionProcessor.

get_directly_constrained_edges() → list[Edge]#

Return all direct constrained edges.

A directly constrained edge is an edge has at list on of its degree of freedom that is constrained by the dimension. Uses enriched constraint point metadata for better matching.

to_constraint() → Constraint#

Convert this dimension processor to a constraint.

class drawing_tools.view.annotations.dimensioning.DimensionAnalyzer(view: View, tolerance: float = 0.001)#

Bases: object

Fluent API for analyzing dimensions within a View context.

This class provides a clean interface for analyzing dimensions using the View’s geometry context without creating tight coupling between Dimension and View.

__init__(view: View, tolerance: float = 0.001)#

Initialize the dimension analyzer with a view context.

Parameters:
  • view – The view containing dimensions and geometries

  • tolerance – Distance tolerance for point-to-edge matching

analyze_dimension(dimension: Dimension) → Constraint | None#

Analyze a single dimension and return its constraint.

Parameters:

dimension – Dimension to analyze

Returns:

Constraint or None if no relationships found

get_directly_linked_edges(dimension: Dimension) → list[Edge]#

Get directly linked edges for a dimension.

Parameters:

dimension – Dimension to analyze

Returns:

List of directly linked edges

get_directly_constrained_edges(dimension: Dimension) → list[Edge]#

Get directly constrained edges for a dimension.

Parameters:

dimension – Dimension to analyze

Returns:

List of directly constrained edges

analyze_all_dimensions() → list[Constraint]#

Analyze all dimensions in the view and return their constraints.

Returns:

List of detected dimension constraints

get_dimension_geometry_constraint_points(dimension: Dimension) → list[volmdlr.Point2D]#

Get the actual geometry points that a dimension constrains.

This method finds the real geometry points (not extension line endpoints) that the dimension is constraining, accounting for the typical 1-2mm offset between extension lines and geometry in technical drawings.

Parameters:

dimension – Dimension to analyze

Returns:

List of actual geometry constraint points (Point2D objects)

get_dimension_extension_line_points(dimension: Dimension) → list[volmdlr.Point2D]#

Get extension line endpoints for a dimension (legacy method).

This returns the extension line endpoints, which may have a small offset from the actual geometry points being constrained.

Parameters:

dimension – Dimension to analyze

Returns:

List of extension line endpoints (Point2D objects)

get_dimension_constraint_points_with_metadata(dimension: Dimension) → list#

Get constraint points with full metadata for a dimension.

Parameters:

dimension – Dimension to analyze

Returns:

List of DimensionConstraintPoint objects

clear_cache() → None#

Clear the constraint points processor cache.

Useful for freeing memory or when dimensions have been modified.

get_cache_stats() → dict#

Get cache statistics for monitoring.

Returns:

Dictionary with cache statistics

drawing_tools.view.annotations.symbol.balloons module#

Balloon symbol wrapper class.

class drawing_tools.view.annotations.symbol.balloons.Balloon(symbol: Symbol)#

Bases: object

Wrapper for balloon symbols with group detection capabilities.

BALLOON_ENTITY_TYPES: ClassVar[tuple[str, ...]] = ('TypeBalloon', 'TypeNote')#
__init__(symbol: Symbol) → None#

Initialize with a balloon Symbol.

The grouping analysis fills three attributes afterwards: group_status (“parent”, “child”, “isolated” or “undefined”), parent_balloon (the parent of a child balloon, None for a parent, an isolated or an undefined one) and group_members (every balloon of this one’s group, itself included). Read group_members rather than rebuilding membership from parent_balloon: an “undefined” group leaves that field None on all of its members, so the walk would collapse each one into a group of its own.

Parameters:

symbol – A dessia_drawing.Symbol — either a genuine balloon (“TypeBalloon”) or a balloon that the drawing mis-classified as a “TypeNote”.

Raises:
  • TypeError – If symbol is not a dessia_drawing.Symbol

  • ValueError – If symbol entity_type is neither “TypeBalloon” nor “TypeNote”

property type_symbol: str#

Return the underlying symbol’s entity type (“TypeBalloon” or “TypeNote”).

property text_content: str#

Return the balloon’s text (e.g., ‘024’, ‘101’).

property leader_count: int#

Return the number of leader arrows directly attached to this balloon.

The leaders and their arrow heads themselves are read straight off the symbol — balloon.symbol.leaders and balloon.symbol.arrow_heads, from dessia_drawing’s AnnotationLeadersMixin — so this class adds no wrapper of its own for them.

property diameter: float#

Return the balloon’s diameter.

Uses the bounding rectangle’s x_length (should be approximately y_length for circular balloons). Alternative approaches may be explored if this doesn’t work reliably.

property radius: float#

Return the balloon’s radius (half of diameter).

property center: Point2D#

Return the balloon’s center position.

Uses the center of the frame’s bounding_rectangle.

property drawing_address: str#

Return the balloon’s drawing address from its symbol frame.

property effective_leader_count: int#

Return the effective number of leaders for this balloon.

  • If parent/isolated: returns own leader count

  • If child: returns the parent balloon’s leader count

Raises:

ValueError – If status is “child” but no parent_balloon is set

overlay_primitives() → list#

Build overlay primitives for this balloon.

The balloon frame is highlighted with a color based on group status. Text labels are added below for multiplicators, for-info flags, or repetitions.

Returns:

List of plot_data primitives.

flag_overlay_primitives() → list#

Build overlay primitives highlighting flag symbols associated with this balloon.

Multiplicator symbols are highlighted in blue, for-info flag symbols in green.

Returns:

List of plot_data primitives, empty if no flags.

static legend_primitives(bounding_rectangle: BoundingRectangle) → list[pld.PlotDataObject]#

Build legend primitives for balloon group status colors, above the given frame.

Parameters:

bounding_rectangle – The frame to place the legend above (typically the view’s).

Returns:

List of plot_data primitives.

__repr__() → str#

Return a string representation of the balloon.

Module contents#

The annotation detections of a view, and the detectors that produce them.

Dimensions, balloons, bonding symbols, section line indicators, aircraft reference lines and aircraft orientation indicators.

class drawing_tools.view.annotations.Balloon(symbol: Symbol)

Bases: object

Wrapper for balloon symbols with group detection capabilities.

BALLOON_ENTITY_TYPES: ClassVar[tuple[str, ...]] = ('TypeBalloon', 'TypeNote')
__init__(symbol: Symbol) → None

Initialize with a balloon Symbol.

The grouping analysis fills three attributes afterwards: group_status (“parent”, “child”, “isolated” or “undefined”), parent_balloon (the parent of a child balloon, None for a parent, an isolated or an undefined one) and group_members (every balloon of this one’s group, itself included). Read group_members rather than rebuilding membership from parent_balloon: an “undefined” group leaves that field None on all of its members, so the walk would collapse each one into a group of its own.

Parameters:

symbol – A dessia_drawing.Symbol — either a genuine balloon (“TypeBalloon”) or a balloon that the drawing mis-classified as a “TypeNote”.

Raises:
  • TypeError – If symbol is not a dessia_drawing.Symbol

  • ValueError – If symbol entity_type is neither “TypeBalloon” nor “TypeNote”

group_status: str | None
parent_balloon: Balloon | None
group_members: list[Balloon]
multiplicator: int | None
multiplicator_symbol: Symbol | None
has_for_info_flag: bool
for_info_flag_symbol: Symbol | None
repetition: int | None
property type_symbol: str

Return the underlying symbol’s entity type (“TypeBalloon” or “TypeNote”).

property text_content: str

Return the balloon’s text (e.g., ‘024’, ‘101’).

property leader_count: int

Return the number of leader arrows directly attached to this balloon.

The leaders and their arrow heads themselves are read straight off the symbol — balloon.symbol.leaders and balloon.symbol.arrow_heads, from dessia_drawing’s AnnotationLeadersMixin — so this class adds no wrapper of its own for them.

property diameter: float

Return the balloon’s diameter.

Uses the bounding rectangle’s x_length (should be approximately y_length for circular balloons). Alternative approaches may be explored if this doesn’t work reliably.

property radius: float

Return the balloon’s radius (half of diameter).

property center: Point2D

Return the balloon’s center position.

Uses the center of the frame’s bounding_rectangle.

property drawing_address: str

Return the balloon’s drawing address from its symbol frame.

property effective_leader_count: int

Return the effective number of leaders for this balloon.

  • If parent/isolated: returns own leader count

  • If child: returns the parent balloon’s leader count

Raises:

ValueError – If status is “child” but no parent_balloon is set

overlay_primitives() → list

Build overlay primitives for this balloon.

The balloon frame is highlighted with a color based on group status. Text labels are added below for multiplicators, for-info flags, or repetitions.

Returns:

List of plot_data primitives.

flag_overlay_primitives() → list

Build overlay primitives highlighting flag symbols associated with this balloon.

Multiplicator symbols are highlighted in blue, for-info flag symbols in green.

Returns:

List of plot_data primitives, empty if no flags.

static legend_primitives(bounding_rectangle: BoundingRectangle) → list[pld.PlotDataObject]

Build legend primitives for balloon group status colors, above the given frame.

Parameters:

bounding_rectangle – The frame to place the legend above (typically the view’s).

Returns:

List of plot_data primitives.

__repr__() → str

Return a string representation of the balloon.

class drawing_tools.view.annotations.BondingSymbol(source_entity: Entity, circle: Edge, label_symbol: TextSearchable | None = None)

Bases: object

Wrapper for a bonding symbol composite: the earth glyph, its label and its leader arrows.

A bonding symbol requires an electrical bonding (metal-to-metal continuity) at the points its leader arrows designate. It is drawn as a circle enclosing the earth glyph, with a number beside it — the bonding TYPE of the title-block METALLISATION table.

__init__(source_entity: Entity, circle: Edge, label_symbol: TextSearchable | None = None) → None

Initialize a bonding symbol from the entity it was detected on.

The detector fills two attributes afterwards, mutually exclusive by convention: leader_notes, the text-less notes carrying the symbol’s own leader arrows, and balloons, the group it is stacked against (closest balloon first) whose leaders it borrows when it has none of its own.

Parameters:
  • source_entity – The entity holding the circle, the earth glyph and the label — a CompositeEntity for the only export shape known so far, hence the loose type: a future detection branch may build symbols from something else.

  • circle – The full-circle edge of the symbol.

  • label_symbol – The text entity carrying the label, when the symbol has one.

Raises:

ValueError – If circle is not a full circle — every geometric property of the symbol reads it, so the mistake is reported here rather than at the first access.

property center: Point2D

Return the circle center — where the symbol’s own leader arrows converge.

property radius: float

Return the circle radius.

property bounding_rectangle: BoundingRectangle

Return the bounding rectangle of the CIRCLE alone — narrower than the drawn symbol.

Deliberate: it is the box the overlay draws on. The label keeps its own (label_symbol.bounding_rectangle) and the whole drawn symbol — circle, glyph and label together — is source_entity.bounding_rectangle.

property label: str

Return the text written NEXT TO the circle (“10”, “47”…), “” when none was found.

The circle itself carries no text: the label is a separate note (label_symbol). Semantically this text is the bonding TYPE of the title-block bonding table, not an identifier of this symbol: several bonding symbols carry the same one without being related to each other.

property leaders: list[Leader]

Return the leader arrows of the symbol itself, one per designated bonding point.

Same contract as the section-line indicators’ leaders: Leader objects, whatever entity carried them — here one text-less note per arrow (leader_notes, filled by the detector after the detection).

property leader_count: int

Return the number of leader arrows the symbol carries ITSELF.

A bonding symbol either carries its own arrows, or is stacked against a balloon group and borrows its leaders — never both, a convention the detector applies when it attaches them. So a count of 0 next to a non-empty balloons means the arrows are the group’s, and their number is master_balloon_leader_count. Read those two rather than deciding for yourself which one takes precedence: the day a drawing shows a symbol legitimately carrying both, the convention changes in one place and every consumer follows.

property balloon_count: int

Return the number of balloons of the group the symbol is stacked against.

0 both when the symbol stands alone and when it carries its own arrows: a symbol that designates its points itself is never attached to a neighbouring balloon.

property master_balloon: Balloon | None

Return the balloon carrying the attached group’s leaders, None when there is no single one.

The parent of the group when the symbol touches a child balloon, the touched balloon itself when it is a parent or an isolated balloon. None both when no balloon is attached and when the group is "undefined" — a group with no leader-carrying balloon, or several, has no single master, and claiming one would invent a fact.

property master_balloon_leader_count: int

Return the leader count of the master balloon, 0 when there is no master.

Read through master_balloon so a single place resolves the master. Balloon.effective_leader_count is deliberately not used: it answers the child’s own question and cannot express “this group has no single master”.

property overlay_lines: list[str]

the label, then what designates its bonding points.

The own-leader count is always stated — reading “Owns 0 leaders” above the group lines is what says the symbol borrows the group’s leaders. The group lines only appear when the symbol is stacked against balloons. The caption drawn on the sheet and tooltip both read these lines, so the two can never diverge.

Type:

Return the overlay caption lines

property tooltip: str

overlay_lines joined, as shown on hover.

Type:

Return the overlay tooltip

overlay_primitives(color: Color | None = None) → list

Build the diagnostic overlay of this bonding symbol, every part in the same color.

Draws a rectangle around the circle carrying tooltip, the symbol’s own leader arrows — so it reads at a glance which bonding points the symbol designates — and the overlay_lines caption, so the assignment is readable without hovering, spaced by CAPTION_LINE_HEIGHT_RATIO.

Parameters:

color – Overlay color. Defaults to blue; callers rendering several symbols pass one color per symbol from a palette.

Returns:

List of plot_data primitives.

leader_overlay_primitives(color: Color | None = None) → list

Redraw the symbol’s own leader arrows in the overlay color.

Parameters:

color – Overlay color (default: blue).

Returns:

List of plot_data primitives, empty when the symbol carries no leader.

__repr__() → str

Return a string representation of the bonding symbol.

class drawing_tools.view.annotations.DimensionAnalyzer(view: View, tolerance: float = 0.001)

Bases: object

Fluent API for analyzing dimensions within a View context.

This class provides a clean interface for analyzing dimensions using the View’s geometry context without creating tight coupling between Dimension and View.

__init__(view: View, tolerance: float = 0.001)

Initialize the dimension analyzer with a view context.

Parameters:
  • view – The view containing dimensions and geometries

  • tolerance – Distance tolerance for point-to-edge matching

analyze_dimension(dimension: Dimension) → Constraint | None

Analyze a single dimension and return its constraint.

Parameters:

dimension – Dimension to analyze

Returns:

Constraint or None if no relationships found

get_directly_linked_edges(dimension: Dimension) → list[Edge]

Get directly linked edges for a dimension.

Parameters:

dimension – Dimension to analyze

Returns:

List of directly linked edges

get_directly_constrained_edges(dimension: Dimension) → list[Edge]

Get directly constrained edges for a dimension.

Parameters:

dimension – Dimension to analyze

Returns:

List of directly constrained edges

analyze_all_dimensions() → list[Constraint]

Analyze all dimensions in the view and return their constraints.

Returns:

List of detected dimension constraints

get_dimension_geometry_constraint_points(dimension: Dimension) → list[volmdlr.Point2D]

Get the actual geometry points that a dimension constrains.

This method finds the real geometry points (not extension line endpoints) that the dimension is constraining, accounting for the typical 1-2mm offset between extension lines and geometry in technical drawings.

Parameters:

dimension – Dimension to analyze

Returns:

List of actual geometry constraint points (Point2D objects)

get_dimension_extension_line_points(dimension: Dimension) → list[volmdlr.Point2D]

Get extension line endpoints for a dimension (legacy method).

This returns the extension line endpoints, which may have a small offset from the actual geometry points being constrained.

Parameters:

dimension – Dimension to analyze

Returns:

List of extension line endpoints (Point2D objects)

get_dimension_constraint_points_with_metadata(dimension: Dimension) → list

Get constraint points with full metadata for a dimension.

Parameters:

dimension – Dimension to analyze

Returns:

List of DimensionConstraintPoint objects

clear_cache() → None

Clear the constraint points processor cache.

Useful for freeing memory or when dimensions have been modified.

get_cache_stats() → dict

Get cache statistics for monitoring.

Returns:

Dictionary with cache statistics

class drawing_tools.view.annotations.OrientationDetectionConfig(min_arrow_edge_count: int = 2)

Bases: object

Configuration for aircraft orientation indicator detection.

Parameters:

min_arrow_edge_count – Minimum number of graphic edges the entity must draw for its caption to count as an orientation indicator rather than a plain note. Two is the lowest an arrow head can be drawn with. Measured on the reference drawings: every one of the 16 captions is drawn with 10 edges (8 distinct strokes – a chevron head, a two-line shaft, two connectors and a tail feather), so this bound rejects none of them; what it rejects is a caption with no arrow at all, which the rule does not accept as a positioning element.

min_arrow_edge_count: int = 2
__init__(min_arrow_edge_count: int = 2) → None
class drawing_tools.view.annotations.OrientationIndicator(source_entity: Entity, arrow_edges: list[Edge], caption_symbol: TextSearchable, text_by_language: dict[str, str])

Bases: object

Wrapper for the arrow and the bilingual caption that say where the aircraft’s front is.

The caption is what carries the meaning – it is read per language, so a check can state what the view says in French and in English – and the arrow is what makes the caption a positioning element rather than a plain note.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>
__init__(source_entity: Entity, arrow_edges: list[Edge], caption_symbol: TextSearchable, text_by_language: dict[str, str]) → None

Initialize an indicator from the entity it was detected on.

Parameters:
  • source_entity – The entity holding the arrow strokes and the caption – a CompositeEntity for the only export shape known so far, hence the loose type: a future detection branch may build indicators from something else.

  • arrow_edges – The graphic edges of that entity, as exported: the arrow strokes. The reference drawings duplicate some of them (10 edges for 8 distinct strokes), which the overlay redraw tolerates.

  • caption_symbol – The nested text entity carrying the bilingual caption.

  • text_by_language – Language name (as named by its LanguageConfig) mapped to the caption line that matched that language, e.g. {"french": "AVANT APPAREIL", "english": "FRONT AIRCRAFT"}.

__repr__() → str

Return a concise representation with the caption and the languages it was read in.

property text_content: str

The whole caption as exported, every language line joined.

property languages: list[str]

Names of the languages the caption was recognized in, alphabetically.

text_for_language(language_name: str) → str | None

Return the caption line recognized for one language, None when that language matched none.

Parameters:

language_name – The name of a LanguageConfig (“french”, “english”…).

Returns:

The matching caption line, or None.

property overlay_lines: list[str]

what the element is, then what it says per language.

The caption drawn on the sheet and tooltip both read these lines, so the two can never diverge.

Type:

The overlay caption lines

property tooltip: str

overlay_lines joined, as shown on hover.

Type:

The overlay tooltip

overlay_primitives(color: Color | None = None) → list

Build the diagnostic overlay of this indicator, every part in the same color.

Draws a rectangle around the whole element carrying tooltip, the arrow strokes redrawn in the overlay color – so the arrow reads at a glance among the view geometry – and the overlay_lines caption, so what the element says is readable without hovering.

Parameters:

color – Overlay color. Defaults to blue; callers rendering several indicators pass one color per indicator from a palette.

Returns:

List of plot_data primitives, empty when the element has no bounding rectangle.

arrow_overlay_primitives(color: Color | None = None) → list

Redraw the arrow strokes in the overlay color.

Parameters:

color – Overlay color (defaults to blue).

Returns:

List of plot_data primitives, empty when the element draws no edge.

class drawing_tools.view.annotations.ReferenceLine(axis: str, value: float, orientation: Literal['horizontal', 'vertical'], source_entity: Entity, label_entity: Entity, name: str = '')

Bases: DessiaObject

A dash-dot line positioning the drawn assembly in the aircraft frame.

Pairs the drawn line with the label that gives it its meaning: without the label a dash-dot line is just an axis, so the label is what makes the element.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>
__init__(axis: str, value: float, orientation: Literal['horizontal', 'vertical'], source_entity: Entity, label_entity: Entity, name: str = '')

Initialize an ReferenceLine.

Parameters:
  • axis – Aircraft axis the line stands for, "X", "Y" or "Z".

  • value – Value along that axis, as read from the label.

  • orientation – Orientation of the line on the sheet, HORIZONTAL or VERTICAL.

  • source_entity – The dash-dot entity drawn on the sheet.

  • label_entity – The text entity naming the axis and the value.

  • name – Optional display name.

__repr__() → str

Return a concise representation with the axis, the value and the orientation.

property bounding_rectangle: BoundingRectangle | None

The rectangle covering both the drawn line and its label.

overlay_primitives(color: str | None = None) → list[PlotDataObject]

Build the diagnostic overlay primitives (rectangle plus label lines).

Parameters:

color – Override color (defaults to blue).

Returns:

Overlay primitives, empty when the element has no bounding rectangle.

plot_data_primitives(color: str | None = None) → list[PlotDataObject]

Get the plot_data primitives for a standalone visualization of this reference line.

Parameters:

color – Override color for the overlay (defaults to blue).

Returns:

The source entities’ own primitives followed by the overlay.

plot_data(color: str | None = None) → None

Visualize this reference line standalone.

Parameters:

color – Override color for the overlay (defaults to blue).

class drawing_tools.view.annotations.ReferenceLineDetectionConfig(dash_dot_curve_type: str = 'DOTTED_DASHED', orientation_tolerance: float = 0.09, max_label_gap_in_font_sizes: float = 1.0, max_label_overhang_in_font_sizes: float = 1.0, default_font_size: float = 5.0, label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$'))

Bases: object

Configuration for aircraft reference line detection.

Every distance is expressed in font sizes of the label being tested, so the detection behaves the same on an A4 detail and on an A0 assembly.

Parameters:
  • dash_dot_curve_type – curve_type an entity must declare to be a reference line candidate.

  • orientation_tolerance – Aperture, as a sine, within which a direction counts as horizontal or vertical. Applied to the lines and to the labels alike; anything further off from both axes is oblique and takes no part. Defaults to the aperture of the helper it is passed to, so the two never disagree.

  • max_label_gap_in_font_sizes – Maximum distance between a label and its line, measured perpendicular to the line.

  • max_label_overhang_in_font_sizes – How far past a line’s end a label may sit and still be considered to run along it.

  • default_font_size – Font size assumed when a label declares none.

  • label_pattern – Compiled regex a label must match, capturing the axis letter and the value.

dash_dot_curve_type: str = 'DOTTED_DASHED'
orientation_tolerance: float = 0.09
max_label_gap_in_font_sizes: float = 1.0
max_label_overhang_in_font_sizes: float = 1.0
default_font_size: float = 5.0
label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$')
__init__(dash_dot_curve_type: str = 'DOTTED_DASHED', orientation_tolerance: float = 0.09, max_label_gap_in_font_sizes: float = 1.0, max_label_overhang_in_font_sizes: float = 1.0, default_font_size: float = 5.0, label_pattern: Pattern = re.compile('^\\s*([XYZ])\\s*([+-]?\\d+(?:\\.\\d+)?)\\s*$')) → None
class drawing_tools.view.annotations.SectionLineIndicator(identifier_info: IdentifierInfo, arrow_locations: list[Point2D], arrow_direction: Vector2D | None = None, source_entities: list[Entity] | None = None, detection_source: str = '', name: str = '')

Bases: DessiaObject

A detected section line indicator.

Represents the symbol showing where a section/auxiliary cut is made, composed of two arrows with the same letter identifier.

Similar to DetectedTable in drawing_tools.table.detection, this class aggregates entities from different sources (TypeNote with leaders, CompositeEntity arrows, standalone letter texts) into a single detected object with its own visualization.

DEFAULT_OVERLAY_COLOR = <plot_data.colors.Color object>
__init__(identifier_info: IdentifierInfo, arrow_locations: list[Point2D], arrow_direction: Vector2D | None = None, source_entities: list[Entity] | None = None, detection_source: str = '', name: str = '')

Initialize a SectionLineIndicator.

Parameters:
  • identifier_info – Parsed identifier information (letter, number, cross-reference, etc.).

  • arrow_locations – Positions of the two arrow tips.

  • arrow_direction – Shared direction vector of both arrows.

  • source_entities – The dessia_drawing entities that compose this indicator. For symbols: [TypeNote]. For composites: [CompositeEntity_i, CompositeEntity_j, TypeNote_label_i, TypeNote_label_j].

  • detection_source – Detection branch that produced this indicator (‘symbols’ or ‘composites’).

  • name – Optional display name.

__repr__() → str

Return a concise string representation with identifier, xref, and detection source.

property leaders: list

This indicator’s two leaders, whichever branch detected it.

Symbols branch: the real leaders of the source entities. Composites branch: leaders reconstructed from the hatched triangles, which own no leader in the model. Both branches return Leader, so arrow_heads — and every overlay or rule built on it — needs no special case.

property arrow_heads: list

The arrow head of each leader — same contract as Entity.arrow_heads.

property has_reconstructed_arrow_heads: bool

Whether this indicator’s arrow heads were reconstructed from geometry, not declared.

property bounding_rectangle: BoundingRectangle | None

Compute the bounding rectangle encompassing all source entities and arrow tips.

overlay_primitives(color: str | None = None) → list[PlotDataObject]

Build all overlay primitives (rectangle + text labels).

Parameters:

color – Override color (default: red).

Returns:

Combined list of rectangle and text primitives.

plot_data_primitives(color: str | None = None) → list[PlotDataObject]

Get plot data primitives for standalone visualization.

Includes primitives from all source entities plus the overlay.

Parameters:

color – Override color for overlay (default: red).

Returns:

List of plot_data primitives.

plot_data(color: str | None = None) → None

Visualize this section line indicator standalone.

Parameters:

color – Override color for overlay (default: red).

class drawing_tools.view.annotations.ViewBondingSymbolDetector(view: View, config: BondingSymbolDetectionConfig | None = None, balloons_provider: Callable[[], list[Balloon]] | None = None)

Bases: object

Detect electrical bonding symbols in a view.

Pipeline:

  1. Every CompositeEntity of the view whose geometries contain one full circle and the earth glyph inside it (a vertical segment from the center plus its horizontal bars) becomes a symbol.

  2. The label is the single text of that same composite — the CAD grouping is authoritative, so no proximity search is needed (checked on the whole reference drawing: the label is nested in the composite for all of its symbols).

  3. The text-less TypeNote symbols whose leader ends on the circle are attached to the symbol as its own leader arrows (BondingSymbol.leader_notes).

  4. For a symbol left without any arrow of its own, the balloon group whose circle it is stacked against is attached as BondingSymbol.balloons — that group’s leaders are the ones it borrows. Steps 3 and 4 are exclusive by convention: at most one is filled.

Usage:

detector = ViewBondingSymbolDetector(view)
bonding_symbols = detector.bonding_symbols   # cached_property
__init__(view: View, config: BondingSymbolDetectionConfig | None = None, balloons_provider: Callable[[], list[Balloon]] | None = None) → None

Initialize the detector.

Parameters:
  • view – A dessia_drawing View object to analyze.

  • config – Detection parameters. Uses defaults if not provided.

  • balloons_provider – Returns the view’s already-analyzed balloons, so the Featured layer can share what it computed. A callable rather than the list itself: balloons are only needed once a symbol has been detected, and asking the Featured layer for them costs a full balloon analysis (and, through it, title parsing, which requires language configs). Analyzed here when not provided.

property bonding_symbols: list[BondingSymbol]

All detected bonding symbols (computed once on first access).

detect_all() → list[BondingSymbol]

Detect this view’s bonding symbols, then attach what each one is assigned.

Steps:

  1. Extract the symbols from the view’s composite entities (the only source known so far).

  2. Attach to each of them the leader arrows ending on its circle.

  3. ONLY for a symbol left without any arrow of its own, attach the balloon group it is stacked against, whose leaders it then borrows.

Making step 3 exclusive of step 2 is a CONVENTION taken here, not a law measured on drawings: none seen so far carries both, and a balloon merely sitting next to a symbol that already designates its own points would be a neighbour rather than a stacking relationship. Should a drawing turn up where a symbol legitimately has both, drop the condition below and let the two coexist.

Returns:

List of detected BondingSymbol instances.

class drawing_tools.view.annotations.ViewDimensionAnalysis(view: View, tolerance: float = 0.001)

Bases: object

View-based dimension analysis for technical drawings.

Provides dimension constraint analysis, edge relationship detection, and geometric constraint extraction within a technical drawing view context.

__init__(view: View, tolerance: float = 0.001)

Initialize the dimension analysis API with a view context.

Parameters:
  • view – The view containing dimensions and geometries

  • tolerance – Distance tolerance for point-to-edge matching

property analyzer: DimensionAnalyzer

Get or create the dimension analyzer.

analyze_dimension(dimension: Dimension) → Constraint | None

Analyze a dimension and return its constraint using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

Constraint or None if no relationships found

get_dimension_linked_edges(dimension: Dimension) → list[Edge]

Get directly linked edges for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of directly linked edges

get_dimension_constrained_edges(dimension: Dimension) → list[Edge]

Get directly constrained edges for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of directly constrained edges

analyze_all_dimensions() → list[Constraint]

Analyze all dimensions in the view and return their constraints.

Returns:

List of all detected constraints

get_dimension_constraint_points(dimension: Dimension) → list

Get constraint points for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of constraint points

get_dimension_constraint_points_with_metadata(dimension: Dimension) → list

Get constraint points with metadata for a dimension using the view’s geometry context.

Parameters:

dimension – The dimension to analyze

Returns:

List of DimensionConstraintPoint objects

class drawing_tools.view.annotations.ViewOrientationDetector(view: View, language_configs: list[LanguageConfig] | None = None, config: OrientationDetectionConfig | None = None)

Bases: object

Detect the aircraft orientation indicators of a view.

Every CompositeEntity of the view whose nested caption matches the orientation patterns of at least one language configuration, and which draws an arrow, becomes an indicator. The caption lines that matched are kept per language, so a check can report what the view says in French and in English.

Usage:

detector = ViewOrientationDetector(view)
indicators = detector.indicators   # cached_property
__init__(view: View, language_configs: list[LanguageConfig] | None = None, config: OrientationDetectionConfig | None = None) → None

Initialize the detector with a view.

Parameters:
  • view – A dessia_drawing View object to analyze.

  • language_configs – The language configurations whose aircraft_orientation_patterns the caption is matched against, and whose name keys the detected texts. Defaults to the French and English defaults, so a view with no language configuration still detects rather than failing – unlike the view title, this detection reads one fixed caption per language, not a parsed title.

  • config – Detection parameters. Uses defaults if not provided.

property indicators: list[OrientationIndicator]

All detected aircraft orientation indicators (computed once on first access).

detect_all() → list[OrientationIndicator]

Detect this view’s aircraft orientation indicators.

Returns:

List of detected OrientationIndicator instances.

class drawing_tools.view.annotations.ViewReferenceLineDetector(view: View, config: ReferenceLineDetectionConfig | None = None)

Bases: object

Detect the aircraft reference lines of a view.

Usage:

detector = ViewReferenceLineDetector(view)
reference_lines = detector.reference_lines
__init__(view: View, config: ReferenceLineDetectionConfig | None = None) → None

Initialize the detector with a view.

Parameters:
  • view – A dessia_drawing View to analyze.

  • config – Detection parameters. Uses defaults if not provided.

property reference_lines: list[ReferenceLine]

All detected aircraft reference lines (computed once on first access).

detect_all() → list[ReferenceLine]

Detect every aircraft reference line of the view.

Returns:

One ReferenceLine per dash-dot line claimed by a label.