drawing_tools.view package#

Subpackages#

Submodules#

drawing_tools.view.featured_view module#

Enhanced view module for extracting features from a view.

class drawing_tools.view.featured_view.FeaturedView(view: View, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#

Bases: DessiaObject

An enhanced representation of a technical drawing view with calculated features.

This class enriches a View object with calculated features that are not directly available in the original View object, including parsed title information, organized annotations, and extracted metadata.

__init__(view: View, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#

Initialize a FeaturedView instance.

Parameters:
  • view – The source View object to enrich with calculated features

  • language_configs – List of language configurations for parsing view titles.

  • title_detection_config – Configuration for title detection parameters.

__getattr__(name: str)#

Delegate attribute access to the underlying view object.

This allows accessing view attributes (passed as name) directly from FeaturedView, e.g., featured_view.annotations instead of featured_view.view.annotations

property main_title_symbol: Entity | None#

Find the main title symbol using pattern-based scoring from language configs.

Gets all TypeNote symbols from the view via get_notes(), then scores each by counting pattern matches (view_type) across all configured languages.

Detection parameters (min_patterns, max_text_length) are read from self.title_detection_config.

property sheet: Sheet#

Get the sheet of the view.

property title: ViewTitle | None#

Get the title of the view.

property type: ViewType | None#

Get the view type as a ViewType enum (e.g., ViewType.FRONT_VIEW, ViewType.SECTION_VIEW).

type_for_language(dominant_language: str | None = None) ViewType | None#

Get the view type as a ViewType enum for a specific language.

Parameters:

dominant_language – The language to use for type detection (e.g., “french”, “english”)

Returns:

The ViewType enum value (e.g., ViewType.FRONT_VIEW, ViewType.SECTION_VIEW), or None if no title

has_type(view_type: ViewType, dominant_language: str | None = None) bool#

Check if the view is of a specific type.

Parameters:
  • view_type – The ViewType enum value to check against

  • dominant_language – The language to use for type detection (e.g., “french”, “english”)

Returns:

True if the view matches the specified type

has_any_type(view_types: list[ViewType], dominant_language: str | None = None) bool#

Check if the view has a type among the specified types.

Parameters:
  • view_types – List of ViewType enum values to check against

  • dominant_language – The language to use for type detection (e.g., “french”, “english”)

Returns:

True if the view matches any of the specified types

static filter_views_of_types(views: list[FeaturedView], view_types: list[ViewType], dominant_language: str | None = None) list[FeaturedView]#

Filter views of specified view types.

Parameters:
  • views – List of views to filter

  • view_types – List of view types to filter by

  • dominant_language – The dominant language to use for filtering

Returns:

List of views that match the specified types

property scale: float#

Get the numeric scale value from the view.

property has_title: bool#

Check if the view has a title.

property geometries: list[Edge]#

Get current geometries from the view.

property dimensions: list[Dimension]#

Get current dimensions from the view.

property tolerances: list[GeometricalTolerance]#

Get current tolerances from the view.

property roughness: list[Roughness]#

Get roughness annotations.

property notes: list[Entity]#

Get all TypeNote symbols from the view.

property section_line_indicators: list[SectionLineIndicator]#

Get all detected section line indicators in this view.

property section_line_indicator_count: int#

Get the number of section line indicators in this view.

property balloons: list[Balloon]#

Get all detected and analyzed balloons in this view.

property balloon_count: int#

Get the number of balloons in this view.

property auxiliary_view_indicators: list[tuple[IdentifierInfo, Entity]]#

Detect auxiliary view indicator annotations (renvois de vues auxiliaires).

Returns TypeNotes matching the identifier pattern with letter "F" and a nearby FillArrow, that are not part of any title or section line indicator. These represent auxiliary view references (e.g., "F2 2/3", "F3"), typically labeled “VUE SUIVANT F…” on the target view.

Returns:

List of (IdentifierInfo, Entity) tuples for each auxiliary view indicator.

property others_annotations: list[Entity]#

Get all the other annotations from the view that aren’t in a specific group.

property annotation_count: dict[str, int]#

Get a count of different annotation types.

property geometry_count: int#

Get the number of geometric entities.

property collector: ViewCollector#

Get the ViewCollector for accessing view-level collectors.

This property provides access to view-level filtering and searching operations, consistent with how View.collector works in dessia_drawing.

Example

dimensions = featured_view.collector.annotations.type.dimensions() geometries = featured_view.collector.geometries.type.line_segments() text_results = featured_view.collector.text.search(“tolerance”) top_most = featured_view.collector.extreme.top_most()

Returns:

ViewCollector instance for the underlying view

get_all_annotations() list[Entity]#

Get all annotations combined in a single list.

get_all_text_content() list[str]#

Extract all text content from the view’s annotations.

collect_view_index_overlay_primitives(view_index: int = 0, color: str | None = None) list#

Collect view index overlay primitives: a rectangle around the view with sheet/view index label.

Delegates to View.collect_view_index_overlay_primitives().

Parameters:
  • view_index – The index of this view in the sheet.

  • color – Override label color (default: blue).

Returns:

List of plot_data primitives (rectangle + text label).

collect_balloon_overlay_primitives() list#

Collect balloon overlay primitives for this view.

Reuses the cached balloons to avoid re-running detection.

Returns:

List of plot_data primitives.

plot_data_balloons#

Specific display tag for PlotData. Add a picture argument.

collect_balloon_flags_overlay_primitives() list#

Collect balloon flag overlay primitives (multiplicators, FM symbols) for this view.

Returns:

List of plot_data primitives.

plot_data_balloon_flags#

Specific display tag for PlotData. Add a picture argument.

collect_section_line_overlay_primitives() list#

Collect section line indicator overlay primitives for this view.

Reuses the cached section_line_indicators to avoid re-running detection.

Returns:

List of plot_data primitives.

plot_data_section_lines#

Specific display tag for PlotData. Add a picture argument.

collect_title_overlay_primitives(color: str | None = None) list#

Collect title overlay primitives (rectangle + text labels) for this view.

Parameters:

color – Override label color (default: blue).

Returns:

List of plot_data primitives, empty if no title.

plot_data_title_view#

Specific display tag for PlotData. Add a picture argument.

collect_auxiliary_view_indicator_overlay_primitives() list#

Collect overlay primitives for auxiliary view indicators.

Each indicator is highlighted with a colored bounding rectangle and labels showing its identifier and optional cross-reference.

Returns:

List of plot_data primitives.

plot_data_auxiliary_view_indicators#

Specific display tag for PlotData. Add a picture argument.

collect_all_identifier_overlay_primitives() list#

Collect overlay primitives for all identifier-bearing objects.

Combines overlays from: - Title (view name with identifier) - Section line indicators - Auxiliary view indicators

Returns:

List of plot_data primitives.

plot_data_all_identifiers#

Specific display tag for PlotData. Add a picture argument.

plot_data_view#

Specific display tag for PlotData. Add a picture argument.

report#

Implementation of a tag for displays.

summary(include_title_summary: bool = True) str#

Generate a comprehensive summary of the view.

Parameters:

include_title_summary – Whether to include detailed title summary in the output

Returns:

A formatted string containing view information

drawing_tools.view.graph module#

Graph representations for geometric constraint analysis.

This module provides specialized graph structures for analyzing geometric relationships in technical drawings, including adjacency graphs based on coincident edge relationships.

class drawing_tools.view.graph.EdgeAdjacencyGraph(view: View, tolerance: float = 0.001, include_incident: bool = False)#

Bases: object

Adjacency graph where nodes represent edges and edges represent coincident relationships.

This graph captures the connectivity structure of a drawing based on which edges share vertices/extremities (coincident relationships) and optionally incident relationships (where one edge’s endpoint lies on another edge).

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

Initialize the edge adjacency graph from a view.

Parameters:
  • view – View containing the edges to analyze

  • tolerance – Tolerance for geometric comparisons

  • include_incident – If True, include INCIDENT relationships as edges in the graph (in addition to COINCIDENT relationships)

get_connected_components() list[set[int]]#

Get connected components of the adjacency graph.

Returns:

List of connected components, each containing edge IDs

get_adjacent_edges(edge: Edge) list[Edge]#

Get edges that are adjacent to the given edge (share vertices).

Parameters:

edge – Edge to find adjacent edges for

Returns:

List of adjacent edges

get_degree(edge: Edge) int#

Get the degree (number of adjacent edges) of an edge.

Parameters:

edge – Edge to get degree for

Returns:

Degree of the edge

get_statistics() dict#

Get statistics about the adjacency graph.

Returns:

Statistics including number of nodes, edges, components, etc.

print_summary() None#

Print a summary of the adjacency graph structure.

plot_data(filepath: str | None = None, show_edge_name: bool = False) None#

Plot the adjacency graph using plot_data.

Parameters:
  • filepath – Optional file path to save the plot

  • show_edge_name – Whether to show edge names on the graph

plot_components(filepath: str | None = None) None#

Create a plot_data visualization showing edge geometries colored by connected components.

This method retrieves the actual Edge instances from the view and colors them according to their connected component membership, making it easy to visualize which edges are connected through coincident relationships.

Parameters:

filepath – Optional file path to save the plot

to_networkx() Graph#

Export the adjacency graph as a NetworkX graph.

Returns:

The adjacency graph with visualization attributes

class drawing_tools.view.graph.GeometryDimensionGraph(view: View, tolerance: float = 0.001)#

Bases: object

Graph that links all the geometric elements of the drawing with the dimensions.

This graph creates a unified representation where: - Point nodes represent vertices (endpoints, centers) - Edge nodes represent geometric elements (lines, arcs, circles) - Dimension nodes represent dimensional constraints - Incidence edges connect points to their edges - Constraint edges connect dimensions to the geometries they constrain

The graph enables analysis of how dimensions relate to geometric elements and facilitates constraint-based reasoning in technical drawings.

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

Initialize the geometry-dimension graph from a view.

Parameters:
  • view – View containing the edges and dimensions to analyze

  • tolerance – Tolerance for geometric comparisons

plot_data_graph(filepath: str | None = None, show_edge_name: bool = False) None#

Plot the geometry-dimension graph using plot_data.

Parameters:
  • filepath – Optional file path to save the plot

  • show_edge_name – Whether to show edge names on the graph

get_statistics() dict#

Get statistics about the geometry-dimension graph.

Returns:

Dictionary with graph statistics

print_summary() None#

Print a summary of the geometry-dimension graph.

print_debug_info(verbose: bool = False) None#

Print debugging information about geometry matching.

Shows statistics about how many geometries were found by identity vs equality, and details about geometries that couldn’t be matched.

Parameters:

verbose – If True, print detailed information about each mismatch

to_networkx() Graph#

Export the geometry-dimension graph as a NetworkX graph.

Returns:

The graph with visualization attributes

drawing_tools.view.title_reader module#

Module for reading and parsing technical drawing view titles.

This module provides multi-language support for extracting structured information from title symbols in technical drawings, including view names, scales, repetitions, and view identifiers.

class drawing_tools.view.title_reader.ViewNameInfo(text_line: TextLine | None = None, name: str | None = None)#

Bases: object

Information about a view name.

Parameters:
  • text_line – The raw line containing the view name (e.g., “VUE A”) Example: TextLine(content=”VUE A”)

  • name – The extracted view name text (e.g., “VUE A”) Example: “VUE A”

text_line: TextLine | None = None#
name: str | None = None#
property is_empty: bool#

Check if the view name info is empty.

__init__(text_line: TextLine | None = None, name: str | None = None) None#
class drawing_tools.view.title_reader.ScaleInfo(text_line: TextLine | None = None, text: str | None = None, value: float | None = None)#

Bases: object

Information about a scale.

Parameters:
  • text_line – The raw line containing the scale Example: TextLine(content=”ECH: 2:1”)

  • text – The extracted scale text (e.g., “2:1”) Example: “2:1”

  • value – The numeric scale value Example: 2.0

text_line: TextLine | None = None#
text: str | None = None#
value: float | None = None#
property is_empty: bool#

Check if the scale info is empty.

static detect_scale_text_line(text_line: TextLine, language_config: LanguageConfig) bool#

Detect if a text line is a scale text line for a specific language configuration.

Parameters:
  • text_line – The text line to analyze

  • language_config – The language configuration to use for detection

Returns:

True if the line contains scale information, False otherwise

static extract_scale_text_line_for_language(text_lines: list[TextLine], language_config: LanguageConfig) TextLine | None#

Extract scale text line for a specific language configuration.

Parameters:
  • text_lines – List of text lines to analyze

  • language_config – The language configuration to use for extraction

Returns:

The text line that contains scale information, or None if none found

static extract_scale_text(text_content: str) str | None#

Extract scale text from a scale text line.

Parameters:

text_content – The text content to extract scale from

Returns:

The scale text (e.g., “2:1”) or None if not found

static extract_scale_value(scale_text: str) float | None#

Extract numeric scale value from scale text.

Parameters:

scale_text – The scale text (e.g., “2:1”)

Returns:

The numeric scale value (e.g., 2.0) or None if invalid

classmethod from_text_lines(text_lines: list[TextLine], language_config: LanguageConfig) ScaleInfo#

Create a ScaleInfo instance from text lines for a specific language configuration.

This method extracts the scale text line and creates a complete ScaleInfo instance.

Parameters:
  • text_lines – List of text lines to analyze

  • language_config – The language configuration to use for extraction

Returns:

A ScaleInfo instance with text_line, text, and value populated

__init__(text_line: TextLine | None = None, text: str | None = None, value: float | None = None) None#
class drawing_tools.view.title_reader.RepetitionInfo(text_line: TextLine | None = None, value: int | None = None)#

Bases: object

Information about repetitions.

Parameters:
  • text_line – The raw line containing the repetition Example: TextLine(content=”VALABLE 2 FOIS”)

  • value – The numeric repetition value Example: 2

text_line: TextLine | None = None#
value: int | None = None#
property is_empty: bool#

Check if the repetition info is empty.

static detect_repetition_text_line(text_line: TextLine, language_config: LanguageConfig) bool#

Detect if a line is a repetition line for a specific language configuration.

Parameters:
  • text_line – The text line to analyze

  • language_config – The language configuration to use for detection

Returns:

True if the line contains repetition information, False otherwise

static extract_repetition_text_line_for_language(text_lines: list[TextLine], language_config: LanguageConfig) TextLine | None#

Extract repetition text line for a specific language configuration.

Parameters:
  • text_lines – List of text lines to analyze

  • language_config – The language configuration to use for extraction

Returns:

The text line that contains repetition information, or None if none found

static find_numeric_repetition(text_content: str, language_config: LanguageConfig) int | None#

Find numeric repetition pattern in a line.

Parameters:
  • text_content – The text content to search

  • language_config – The language configuration to use

Returns:

The numeric repetition value or None if not found

static find_word_repetition(text_content: str, language_config: LanguageConfig) int | None#

Find word-based repetition pattern in a line.

Parameters:
  • text_content – The text content to search

  • language_config – The language configuration to use

Returns:

The numeric repetition value from word mapping or None if not found

static extract_repetitions_value(text_content: str, language_config: LanguageConfig) int | None#

Extract repetitions value from a repetition line.

Tries numeric patterns first, then word-based patterns.

Parameters:
  • text_content – The text content to extract from

  • language_config – The language configuration to use

Returns:

The numeric repetition value or None if not found

classmethod from_text_lines(text_lines: list[TextLine], language_config: LanguageConfig) RepetitionInfo#

Create a RepetitionInfo instance from text lines for a specific language configuration.

This method extracts the repetition text line and creates a complete RepetitionInfo instance.

Parameters:
  • text_lines – List of text lines to analyze

  • language_config – The language configuration to use for extraction

Returns:

A RepetitionInfo instance with text_line and value populated

__init__(text_line: TextLine | None = None, value: int | None = None) None#
class drawing_tools.view.title_reader.ViewTypeInfo(type: ViewType | None = None)#

Bases: object

Information about a view type.

Parameters:

type – The extracted view type (e.g., ViewType.SECTION_VIEW, ViewType.FRONT_VIEW, ViewType.ISOMETRIC_VIEW) Example: ViewType.SECTION_VIEW

type: ViewType | None = None#
property is_empty: bool#

Check if the view type info is empty.

__init__(type: ViewType | None = None) None#
class drawing_tools.view.title_reader.TitleParsedResult(view_name_by_language: dict[str, str], view_type_by_language: dict[str, ViewTypeInfo], identifiers_by_language: dict[str, IdentifierInfo], scale_by_language: dict[str, ScaleInfo], repetition_by_language: dict[str, RepetitionInfo], additional_text_lines: list[TextLine] | None)#

Bases: object

Store the result of TitleParser.

This dataclass encapsulates all parsing results from multi-language title analysis, organizing data both by language and providing convenient flat access to all values.

Parameters:
  • view_name_by_language – Dictionary mapping language names to view name information. Each language has a ViewNameInfo object. Example: {“french”: ViewNameInfo(..), “english”: ViewNameInfo(…)}

  • view_type_by_language – Dictionary mapping language names to view type information. Each language has a ViewTypeInfo object. Example: {“french”: ViewTypeInfo(…), “english”: ViewTypeInfo(…)}

  • identifiers_by_language – Dictionary mapping language names to identifier information. Each language has a IdentifierInfo object. Example: {“french”: IdentifierInfo(…), “english”: IdentifierInfo(…)}

  • scale_by_language – Dictionary mapping language names to scale information. Each language has a ScaleInfo object. Example: {“french”: ScaleInfo(…), “english”: ScaleInfo(…)}

  • repetition_by_language – Dictionary mapping language names to repetition information. Each language has a RepetitionInfo object. Example: {“french”: RepetitionInfo(…), “english”: RepetitionInfo(…)}

  • additional_text_lines – Any text content that wasn’t categorized as view names, repetitions, or scale information. None if all text was categorized. Example: [TextLine(content=”Additional text line”)]

view_name_by_language: dict[str, str]#
view_type_by_language: dict[str, ViewTypeInfo]#
identifiers_by_language: dict[str, IdentifierInfo]#
scale_by_language: dict[str, ScaleInfo]#
repetition_by_language: dict[str, RepetitionInfo]#
additional_text_lines: list[TextLine] | None#
property view_name_text_lines: list[TextLine]#

Get all view names from all languages as a flat list.

property scale_text_lines: list[TextLine]#

Get all scale lines from all languages as a flat list.

property repetition_text_lines: list[TextLine]#

Get all repetition texts from all languages as a flat list.

__init__(view_name_by_language: dict[str, str], view_type_by_language: dict[str, ViewTypeInfo], identifiers_by_language: dict[str, IdentifierInfo], scale_by_language: dict[str, ScaleInfo], repetition_by_language: dict[str, RepetitionInfo], additional_text_lines: list[TextLine] | None) None#
class drawing_tools.view.title_reader.TitleParser(language_configs: list[LanguageConfig])#

Bases: object

Multi-language parser for technical drawing title blocks.

This parser extracts structured information from title symbols in technical drawings. It supports multiple languages simultaneously and can detect view names, scales, and repetition information across different linguistic contexts.

The parser uses view_type_patterns from each LanguageConfig to match view names, view types, and identifiers in a single pass per text line. A single text line can match multiple languages (e.g., “DETAIL 1” matches both French and English).

Parameters:

language_configs – List of language configurations used for parsing. Each configuration defines patterns and keywords for a specific language.

__init__(language_configs: list[LanguageConfig])#

Initialize a TitleParser instance.

Parameters:

language_configs – A list of LanguageConfig for each desired supported language for the parser. Please relate to LanguageConfig documentation for more detail on how to properly set it.

parse_text_lines(text_lines: list[TextLine]) TitleParsedResult#

Parse text lines and extract all information.

class drawing_tools.view.title_reader.TitleDetectionConfig(min_patterns: int = 1, max_text_length: int | None = 200)#

Bases: DessiaObject

Configuration parameters for view title detection.

Parameters:
  • min_patterns – Minimum score threshold for a candidate to be considered a title. Default: 1 (at least one language must match).

  • max_text_length – Maximum total text length for a candidate note. Notes exceeding this are filtered out (likely technical notes, not titles). Set to None to disable. Default: 200.

__init__(min_patterns: int = 1, max_text_length: int | None = 200)#

Initialize title detection configuration.

drawing_tools.view.title_reader.count_title_pattern_matches(text_content: str, language_configs: list[LanguageConfig]) int#

Count view_type pattern matches for a candidate title text across all language configs.

Each language config contributes +1 if any of its view_type_patterns matches. Max = len(language_configs).

Parameters:
  • text_content – The text content to score

  • language_configs – Language configurations providing the patterns

Returns:

Cumulative score across all languages

class drawing_tools.view.title_reader.ViewTitle(source_entity: Entity, language_configs: list[LanguageConfig], name: str = '')#

Bases: DessiaObject

A comprehensive representation of a view title symbol organized by text lines.

This class analyzes both the structural aspects (texts, styles, positions) and semantic content (view name, scale, repetitions) of title symbols, with methods that work on a line-by-line basis.

__init__(source_entity: Entity, language_configs: list[LanguageConfig], name: str = '')#

Initialize a ViewTitle instance.

Parameters:
  • source_entity – The source annotation entity (currently Symbol) that represents the title

  • language_configs – List of language configurations used for parsing. Each configuration defines patterns and keywords for a specific language.

  • name – Optional name for the ViewTitle instance

property text_lines: list[TextLine]#

Get the text lines grouped by y-coordinate.

property lines_content: list[str]#

Get the text content as list of strings.

property line_count: int#

Get the number of text lines in the title.

property has_multiple_lines: bool#

Check if the title has multiple text lines.

property detected_languages: list[str]#

Get list of detected languages in the title.

property parsed_result: TitleParsedResult#

Get parsed semantic information from the title using TitleParser.

property view_name_by_language: dict[str, list[str]]#

Get view names organized by language.

property view_type_by_language: dict[str, ViewTypeInfo]#

Get view types organized by language.

property identifiers_by_language: dict[str, dict[str, str]]#

Get identifiers organized by language.

property scale_by_language: dict[str, dict[str, str]]#

Get scales organized by language.

property repetition_by_language: dict[str, dict[str, str]]#

Get repetitions organized by language.

property additional_text_lines: list[TextLine] | None#

Get any additional information not categorized elsewhere.

view_type(dominant_language: str | None = None) ViewType | None#

Get unified view type.

If dominant_language is None, the view type is the one identified for all languages. An error is raised if different view types are identified for different languages. If dominant_language is a specific language, the view type is the one identified for that language.

scale(dominant_language: str | None = None) float | None#

Get unified scale value.

If dominant_language is None, the scale value is the one identified for all languages. An error is raised if different scale values are identified for different languages. If dominant_language is a specific language, the scale value is the one identified for that language.

repetition(dominant_language: str | None = None) int | None#

Get unified repetition value.

If dominant_language is None, the repetition value is the one identified for all languages. An error is raised if different repetition values are identified for different languages. If dominant_language is a specific language, the repetition value is the one identified for that language.

get_raw_text() str#

Get all text content as a single string.

report#

Implementation of a tag for displays.

summary() str#

Generate a summary of the title. Alias for report().

DEFAULT_LABEL_COLOR = <plot_data.colors.Color object>#
overlay_primitives(color: str | None = None) list[PlotDataObject]#

Build all title overlay primitives (rectangle + text labels).

Parameters:

color – Override label color (default: blue).

Returns:

Combined list of rectangle and text primitives.

plot_data_view#

Specific display tag for PlotData. Add a picture argument.

__repr__() str#

Return a string representation of the ViewTitle.

Module contents#

View analysis module.

This module contains analysis capabilities for technical drawing views.