drawing_tools.view.annotations package#

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_mapperPointToEdgeMapper 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_balloon: Symbol)#

Bases: object

Wrapper for balloon symbols with group detection capabilities.

__init__(symbol_balloon: Symbol) None#

Initialize with a Symbol of subtype TypeBalloon.

Parameters:

symbol_balloon – A dessia_drawing.Symbol object with subtype “TypeBalloon” (collected with entity_subtypes=[“TypeBalloon”])

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

  • ValueError – If symbol_balloon subtype is not “TypeBalloon”

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.

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(x: float, y: float) list#

Build legend primitives for balloon group status colors.

Parameters:
  • x – X position of the legend (top-left).

  • y – Y position of the legend (top-left).

Returns:

List of plot_data primitives.

__repr__() str#

Return a string representation of the balloon.

Module contents#

Annotations module for dimension analysis.

class drawing_tools.view.annotations.Balloon(symbol_balloon: Symbol)#

Bases: object

Wrapper for balloon symbols with group detection capabilities.

__init__(symbol_balloon: Symbol) None#

Initialize with a Symbol of subtype TypeBalloon.

Parameters:

symbol_balloon – A dessia_drawing.Symbol object with subtype “TypeBalloon” (collected with entity_subtypes=[“TypeBalloon”])

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

  • ValueError – If symbol_balloon subtype is not “TypeBalloon”

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.

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(x: float, y: float) list#

Build legend primitives for balloon group status colors.

Parameters:
  • x – X position of the legend (top-left).

  • y – Y position of the legend (top-left).

Returns:

List of plot_data primitives.

__repr__() str#

Return a string representation of the balloon.

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.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 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.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