drawing_tools package#
Subpackages#
- drawing_tools.config package
- Submodules
- drawing_tools.config.view_language_configs module
- drawing_tools.config.view_types_config module
ViewTypeViewType.BACKGROUND_VIEWViewType.FRONT_VIEWViewType.SECTION_VIEWViewType.ISOMETRIC_VIEWViewType.DETAIL_VIEWViewType.AUXILIARY_VIEWViewType.UNFOLDED_VIEWViewType.EXPLODED_VIEWViewType.LHS_VIEWViewType.RHS_VIEWViewType.BOTTOM_VIEWViewType.REAR_VIEWViewType.TOP_VIEWViewType.LEVELED_SECTION_VIEWViewType.ROTATED_VIEW_ONViewType.TYP_SECTION_VIEWViewType.SECTION_CUTViewType.TYP_SECTION_CUTViewType.__str__()ViewType.all_types()ViewType.get_group()ViewType.__new_member__()
- Module contents
- drawing_tools.constraints package
- Submodules
- drawing_tools.constraints.core module
ConstraintTypeConstraintType.COINCIDENTConstraintType.DISTANCEConstraintType.LENGTHConstraintType.INCIDENCEConstraintType.PARALLELConstraintType.COLLINEARConstraintType.PERPENDICULARConstraintType.ANGULARConstraintType.TANGENTConstraintType.CONCENTRICConstraintType.RADIUSConstraintType.DIAMETERConstraintType.EQUAL_RADIUSConstraintType.EQUAL_LENGTHConstraintType.FIX_POINTConstraintType.HORIZONTALConstraintType.VERTICAL
Constraint
- Module contents
- drawing_tools.helpers package
- drawing_tools.sheet package
- Submodules
- drawing_tools.sheet.featured_sheet module
FeaturedSheetFeaturedSheet.__init__()FeaturedSheet.__getattr__()FeaturedSheet.formatFeaturedSheet.viewsFeaturedSheet.get_background_view()FeaturedSheet.views_of_types()FeaturedSheet.views_of_type()FeaturedSheet.views_of_types_by_reading_order()FeaturedSheet.collectorFeaturedSheet.background_viewFeaturedSheet.front_viewsFeaturedSheet.section_viewsFeaturedSheet.isometric_viewsFeaturedSheet.detail_viewsFeaturedSheet.auxiliary_viewsFeaturedSheet.other_viewsFeaturedSheet.balloonsFeaturedSheet.section_line_indicatorsFeaturedSheet.auxiliary_view_indicatorsFeaturedSheet.setsFeaturedSheet.has_setsFeaturedSheet.get_set_for_view()FeaturedSheet.get_views_in_set()FeaturedSheet.views_by_setFeaturedSheet.plot_data_view_indexesFeaturedSheet.plot_data_grid_referenceFeaturedSheet.collect_title_overlay_primitives()FeaturedSheet.collect_section_line_overlay_primitives()FeaturedSheet.collect_table_overlay_primitives()FeaturedSheet.collect_balloon_overlay_primitives()FeaturedSheet.plot_data_balloonsFeaturedSheet.plot_data_section_linesFeaturedSheet.collect_balloon_flags_overlay_primitives()FeaturedSheet.plot_data_balloon_flagsFeaturedSheet.collect_sets_overlay_primitives()FeaturedSheet.plot_data_setsFeaturedSheet.plot_data_tablesFeaturedSheet.plot_data_title_viewFeaturedSheet.collect_auxiliary_view_indicator_overlay_primitives()FeaturedSheet.plot_data_auxiliary_view_indicatorsFeaturedSheet.collect_all_identifier_overlay_primitives()FeaturedSheet.plot_data_all_identifiersFeaturedSheet.plot_data_viewFeaturedSheet.reportFeaturedSheet.summary()
- Module contents
FeaturedSheetFeaturedSheet.__init__()FeaturedSheet.__getattr__()FeaturedSheet.formatFeaturedSheet.viewsFeaturedSheet.get_background_view()FeaturedSheet.views_of_types()FeaturedSheet.views_of_type()FeaturedSheet.views_of_types_by_reading_order()FeaturedSheet.collectorFeaturedSheet.background_viewFeaturedSheet.front_viewsFeaturedSheet.section_viewsFeaturedSheet.isometric_viewsFeaturedSheet.detail_viewsFeaturedSheet.auxiliary_viewsFeaturedSheet.other_viewsFeaturedSheet.balloonsFeaturedSheet.section_line_indicatorsFeaturedSheet.auxiliary_view_indicatorsFeaturedSheet.setsFeaturedSheet.has_setsFeaturedSheet.get_set_for_view()FeaturedSheet.get_views_in_set()FeaturedSheet.views_by_setFeaturedSheet.plot_data_view_indexesFeaturedSheet.plot_data_grid_referenceFeaturedSheet.collect_title_overlay_primitives()FeaturedSheet.collect_section_line_overlay_primitives()FeaturedSheet.collect_table_overlay_primitives()FeaturedSheet.collect_balloon_overlay_primitives()FeaturedSheet.plot_data_balloonsFeaturedSheet.plot_data_section_linesFeaturedSheet.collect_balloon_flags_overlay_primitives()FeaturedSheet.plot_data_balloon_flagsFeaturedSheet.collect_sets_overlay_primitives()FeaturedSheet.plot_data_setsFeaturedSheet.plot_data_tablesFeaturedSheet.plot_data_title_viewFeaturedSheet.collect_auxiliary_view_indicator_overlay_primitives()FeaturedSheet.plot_data_auxiliary_view_indicatorsFeaturedSheet.collect_all_identifier_overlay_primitives()FeaturedSheet.plot_data_all_identifiersFeaturedSheet.plot_data_viewFeaturedSheet.reportFeaturedSheet.summary()
- drawing_tools.table package
- Submodules
- drawing_tools.table.core module
TableLineTableLine.__init__()TableLine.connectionsTableLine.connection_countTableLine.add_connection()TableLine.from_edge()TableLine.virtual()TableLine.startTableLine.endTableLine.is_verticalTableLine.is_horizontalTableLine.line_coordinateTableLine.lengthTableLine.is_virtualTableLine.span_rangesTableLine.merge_with()TableLine.has_gapsTableLine.gap_positionsTableLine.total_coverageTableLine.coverage_ratioTableLine.is_on_range()TableLine.find_connected_component()
TableCellTableCell.__init__()TableCell.is_column_mergedTableCell.is_row_mergedTableCell.column_spanTableCell.row_spanTableCell.widthTableCell.heightTableCell.centerTableCell.areaTableCell.bounding_rectangleTableCell.has_contentTableCell.content_countTableCell.contains_point()TableCell.contains_entity()TableCell.add_content()TableCell.get_text_content()TableCell.get_ordered_content()TableCell.get_combined_text()TableCell.contains_text()TableCell.debug_content_order()TableCell.plot_data_primitives()
GridCellTableGridTableStructure
- drawing_tools.table.detection module
is_symbol_with_rectangle_frame()CandidatePreparationConfigTableGenerationConfigTableGenerationConfig.toleranceTableGenerationConfig.min_table_sizeTableGenerationConfig.min_cell_sizeTableGenerationConfig.min_edges_for_tableTableGenerationConfig.min_lines_in_componentTableGenerationConfig.intersection_toleranceTableGenerationConfig.min_lines_for_extentTableGenerationConfig.__init__()
TableSelectionConfigDetectedTableDetectedTable.__init__()DetectedTable.bounding_rectangleDetectedTable.areaDetectedTable.nb_cellsDetectedTable.nb_rowsDetectedTable.nb_colsDetectedTable.total_content_countDetectedTable.non_empty_cellsDetectedTable.get_table_cell_at()DetectedTable.get_grid_cell_at()DetectedTable.get_all_content()DetectedTable.find_table_cells_with_text()DetectedTable.plot_data_primitives()DetectedTable.plot_data()
TableGeneratorSheetTableDetectorSheetTableDetector.__init__()SheetTableDetector.tablesSheetTableDetector.detection_dataSheetTableDetector.get_title_block_annotations()SheetTableDetector.get_title_block_table()SheetTableDetector.detect_title_block()SheetTableDetector.detect_view_tables()SheetTableDetector.detect_tables_in_background_view()SheetTableDetector.detect_all_tables()SheetTableDetector.get_tables_summary()SheetTableDetector.collect_overlay_primitives()
- drawing_tools.table.title_block module
- drawing_tools.table.utils module
- Module contents
SheetTableDetectorSheetTableDetector.__init__()SheetTableDetector.tablesSheetTableDetector.detection_dataSheetTableDetector.get_title_block_annotations()SheetTableDetector.get_title_block_table()SheetTableDetector.detect_title_block()SheetTableDetector.detect_view_tables()SheetTableDetector.detect_tables_in_background_view()SheetTableDetector.detect_all_tables()SheetTableDetector.get_tables_summary()SheetTableDetector.collect_overlay_primitives()
- drawing_tools.view package
- Subpackages
- Submodules
- drawing_tools.view.featured_view module
FeaturedViewFeaturedView.__init__()FeaturedView.__getattr__()FeaturedView.main_title_symbolFeaturedView.sheetFeaturedView.titleFeaturedView.typeFeaturedView.type_for_language()FeaturedView.has_type()FeaturedView.has_any_type()FeaturedView.filter_views_of_types()FeaturedView.scaleFeaturedView.has_titleFeaturedView.geometriesFeaturedView.dimensionsFeaturedView.tolerancesFeaturedView.roughnessFeaturedView.notesFeaturedView.section_line_indicatorsFeaturedView.section_line_indicator_countFeaturedView.balloonsFeaturedView.balloon_countFeaturedView.auxiliary_view_indicatorsFeaturedView.others_annotationsFeaturedView.annotation_countFeaturedView.geometry_countFeaturedView.collectorFeaturedView.get_all_annotations()FeaturedView.get_all_text_content()FeaturedView.collect_view_index_overlay_primitives()FeaturedView.collect_balloon_overlay_primitives()FeaturedView.plot_data_balloonsFeaturedView.collect_balloon_flags_overlay_primitives()FeaturedView.plot_data_balloon_flagsFeaturedView.collect_section_line_overlay_primitives()FeaturedView.plot_data_section_linesFeaturedView.collect_title_overlay_primitives()FeaturedView.plot_data_title_viewFeaturedView.collect_auxiliary_view_indicator_overlay_primitives()FeaturedView.plot_data_auxiliary_view_indicatorsFeaturedView.collect_all_identifier_overlay_primitives()FeaturedView.plot_data_all_identifiersFeaturedView.plot_data_viewFeaturedView.reportFeaturedView.summary()
- drawing_tools.view.graph module
EdgeAdjacencyGraphEdgeAdjacencyGraph.__init__()EdgeAdjacencyGraph.get_connected_components()EdgeAdjacencyGraph.get_adjacent_edges()EdgeAdjacencyGraph.get_degree()EdgeAdjacencyGraph.get_statistics()EdgeAdjacencyGraph.print_summary()EdgeAdjacencyGraph.plot_data()EdgeAdjacencyGraph.plot_components()EdgeAdjacencyGraph.to_networkx()
GeometryDimensionGraph
- drawing_tools.view.title_reader module
ViewNameInfoScaleInfoRepetitionInfoRepetitionInfo.text_lineRepetitionInfo.valueRepetitionInfo.is_emptyRepetitionInfo.detect_repetition_text_line()RepetitionInfo.extract_repetition_text_line_for_language()RepetitionInfo.find_numeric_repetition()RepetitionInfo.find_word_repetition()RepetitionInfo.extract_repetitions_value()RepetitionInfo.from_text_lines()RepetitionInfo.__init__()
ViewTypeInfoTitleParsedResultTitleParsedResult.view_name_by_languageTitleParsedResult.view_type_by_languageTitleParsedResult.identifiers_by_languageTitleParsedResult.scale_by_languageTitleParsedResult.repetition_by_languageTitleParsedResult.additional_text_linesTitleParsedResult.view_name_text_linesTitleParsedResult.scale_text_linesTitleParsedResult.repetition_text_linesTitleParsedResult.__init__()
TitleParserTitleDetectionConfigcount_title_pattern_matches()ViewTitleViewTitle.__init__()ViewTitle.text_linesViewTitle.lines_contentViewTitle.line_countViewTitle.has_multiple_linesViewTitle.detected_languagesViewTitle.parsed_resultViewTitle.view_name_by_languageViewTitle.view_type_by_languageViewTitle.identifiers_by_languageViewTitle.scale_by_languageViewTitle.repetition_by_languageViewTitle.additional_text_linesViewTitle.view_type()ViewTitle.scale()ViewTitle.repetition()ViewTitle.get_raw_text()ViewTitle.reportViewTitle.summary()ViewTitle.DEFAULT_LABEL_COLORViewTitle.overlay_primitives()ViewTitle.plot_data_viewViewTitle.__repr__()
- Module contents
Submodules#
drawing_tools.featured_drawing module#
Enhanced drawing module for extracting features from a drawing.
- class drawing_tools.featured_drawing.FeaturedDrawing(drawing: Drawing, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Bases:
DessiaObjectAn enhanced representation of a technical drawing with calculated features.
This class enriches a Drawing object with calculated features that are not directly available in the original Drawing object, including featured sheets, organized annotations, and extracted metadata.
- __init__(drawing: Drawing, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Initialize a FeaturedDrawing instance.
- Parameters:
drawing – The source Drawing 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 drawing object.
This allows accessing drawing attributes (passed as name) directly from FeaturedDrawing, e.g., featured_drawing.sheets instead of featured_drawing.drawing.sheets
- property sheets: list[FeaturedSheet]#
Get all featured sheets in the drawing.
- property views: list[FeaturedView]#
Get all featured views in the drawing.
- views_of_types(view_types: list[ViewType], dominant_language: str | None = None) list[FeaturedView]#
Extract views of specified view types from the drawing.
- Parameters:
view_types – List of ViewType enum values to filter by
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified types across all sheets
- views_of_types_by_reading_order(view_types: list[ViewType], dominant_language: str | None = None) list[FeaturedView]#
Get views of specified view types sorted by reading order in the drawing.
- Parameters:
view_types – List of ViewType enum values to filter by
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified types, sorted by reading order
- property collector: DrawingCollector#
Get the DrawingCollector for accessing drawing-level collectors.
This property provides access to drawing-level filtering and searching operations, consistent with how Sheet.collector and View.collector work in dessia_drawing.
Example
symbols = featured_drawing.collector.type.symbols(entity_subtypes=[“TypeBalloon”]) dimensions = featured_drawing.collector.type.dimensions() text_results = featured_drawing.collector.text.search(“tolerance”)
- Returns:
DrawingCollector instance for the underlying drawing
- plot_data_view_indexes#
Specific display tag for PlotData. Add a picture argument.
- plot_data_grid_reference#
Specific display tag for PlotData. Add a picture argument.
- plot_data_balloons#
Specific display tag for PlotData. Add a picture argument.
- plot_data_section_lines#
Specific display tag for PlotData. Add a picture argument.
- plot_data_balloon_flags#
Specific display tag for PlotData. Add a picture argument.
- plot_data_sets#
Specific display tag for PlotData. Add a picture argument.
- plot_data_tables#
Specific display tag for PlotData. Add a picture argument.
- plot_data_title_view#
Specific display tag for PlotData. Add a picture argument.
- plot_data_auxiliary_view_indicators#
Specific display tag for PlotData. Add a picture argument.
- 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.
drawing_tools.functions module#
Functions for drawing tools.
- drawing_tools.functions.remove_sorted_keywords_from_string(string: str, keywords: list[str]) str#
Remove sorted keywords from a string.
- Parameters:
string – The string to process
keywords – List of keywords to remove (sorted by length, longest first)
- Returns:
The string with keywords removed
- drawing_tools.functions.identify_duplicate_in_list(items: list) list#
Identify duplicate items in a list.
- Parameters:
items – List of items to check for duplicates
- Returns:
List containing only the duplicate items
- drawing_tools.functions.get_supposed_letters_list(nb_items: int, forbidden_letters: list[str] | None = None) list[str]#
Get supposed letters list.
- Parameters:
nb_items – Number of items to get
forbidden_letters – List of forbidden letters
- Returns:
List of supposed letters
- drawing_tools.functions.get_supposed_numbers_list(nb_items: int) list[int]#
Get supposed numbers list.
- Parameters:
nb_items – Number of items to get
- Returns:
List of supposed numbers
- drawing_tools.functions.get_forbidden_letters_for_view_types(view_types: list[ViewType]) list[str]#
Get forbidden letters for a list of view types.
/!Does not take into account different forbidden letters for each view type. This function returns a union of all forbidden letters from all provided view types, which means it treats all view types equally. For more precise handling, consider checking forbidden letters per view type individually.
- Parameters:
view_types – List of ViewType enum values
- Returns:
List of forbidden letters (uppercase)
drawing_tools.title_block module#
Title Block Module.
A comprehensive module for defining and managing title blocks in engineering technical drawings. Based on ISO 7200:2004 standard.
- class drawing_tools.title_block.TitleBlock(legal_owner: str, identification_number: str, date_of_issue: str, title: str, page_number: int = 1, part_ids: list[str] | None = None, revision: str | None = None, number_of_pages: int | None = None, material: str | None = None, weight: str | None = None, general_tolerances: str | None = None, surface_roughness: str | None = None, creator: str | None = None, approver: str | None = None, scale: str | None = None, projection_method: str | None = None, drawing_size: str | None = None, status: str | None = None, zone: str | None = None, safety_class: str | None = None, ecr_ecp_eco: str | None = None, protection_standard: str | None = None, parent_table: DetectedTable | None = None, name: str = '')#
Bases:
DessiaObjectMain title block container following ISO 7200:2004.
- __init__(legal_owner: str, identification_number: str, date_of_issue: str, title: str, page_number: int = 1, part_ids: list[str] | None = None, revision: str | None = None, number_of_pages: int | None = None, material: str | None = None, weight: str | None = None, general_tolerances: str | None = None, surface_roughness: str | None = None, creator: str | None = None, approver: str | None = None, scale: str | None = None, projection_method: str | None = None, drawing_size: str | None = None, status: str | None = None, zone: str | None = None, safety_class: str | None = None, ecr_ecp_eco: str | None = None, protection_standard: str | None = None, parent_table: DetectedTable | None = None, name: str = '')#
Initialize title block with extracted information.
- Parameters:
legal_owner – The name of the company or individual that owns the drawing’s copyright and content. Corresponds to ISO 7200 field ‘a’.
identification_number – The primary, unique identifier for the drawing, such as a part or drawing number. Corresponds to ISO 7200 field ‘b’.
date_of_issue – The date when this version of the drawing was officially issued or released, preferably in YYYY-MM-DD format. Corresponds to ISO 7200 field ‘f’.
title – The descriptive title of the drawing’s subject. This typically describes the part, assembly, or system shown. Corresponds to ISO 7200 field ‘d’.
page_number – The number of the current sheet. Defaults to 1. Corresponds to ISO 7200 field ‘g’.
part_ids – A list of any additional identification numbers associated with the drawing.
revision – The revision identifier (e.g., ‘A’, ‘B’, ‘1.0’) indicating the version of the drawing. Corresponds to ISO 7200 field ‘c’.
number_of_pages – The total number of sheets in the complete drawing set. Corresponds to ISO 7200 field ‘h’.
material – The material specification for the part shown in the drawing (e.g., ‘EN_10027 - S235JR’).
weight – The mass of the object depicted in the drawing, including units (e.g., ‘0,04 kg’).
general_tolerances – The standard for general tolerances to be applied unless otherwise specified (e.g., ‘ISO 2768-mK’).
surface_roughness – The standard or default requirement for surface texture.
creator – The name of the person who created or drew the drawing. Corresponds to ISO 7200 field ‘e’ (Drawn by).
modified_by – The name of the person who last modified the drawing.
approver – The name of the person who approved the drawing for release.
scale – The primary scale of the drawing (e.g., ‘1:1’, ‘1:2’).
projection_method – The projection method used (e.g., ‘First angle’, ‘Third angle’), often represented by the ISO projection symbol.
drawing_size – The size of the drawing sheet according to ISO 5457 (e.g., ‘A3’, ‘A4’).
status – The current lifecycle status of the drawing (e.g., ‘In work’, ‘Released’, ‘Obsolete’).
zone – A reference to a specific zone on the drawing grid.
safety_class – Any safety classification applicable to the part or drawing.
ecr_ecp_eco – Engineering Change Request/Proposal/Order number associated with this drawing version.
protection_standard – The standard for any protective treatment or coating.
parent_table – A reference to the DetectedTable object from which this title block was extracted.
extraction_timestamp – The ISO-formatted timestamp of when the extraction was performed.
name – An optional name for the TitleBlock instance.
Module contents#
drawing_tools - High-level analysis tools for technical drawings.
This package provides comprehensive technical drawing analysis capabilities, from low-level geometric constraints to high-level semantic information extraction.
- class drawing_tools.Constraint(type: ~drawing_tools.constraints.core.ConstraintType, geometries: list[Geometry | ~volmdlr.core_compiled.Point2D], metadata: dict = <factory>)#
Bases:
objectConstraint between primitives.
- type: ConstraintType#
- class drawing_tools.ConstraintType(*values)#
Bases:
EnumTypes of constraints.
- COINCIDENT = 1#
- DISTANCE = 2#
- LENGTH = 3#
- INCIDENCE = 4#
- PARALLEL = 5#
- COLLINEAR = 6#
- PERPENDICULAR = 7#
- ANGULAR = 8#
- TANGENT = 9#
- CONCENTRIC = 10#
- RADIUS = 11#
- DIAMETER = 12#
- EQUAL_RADIUS = 13#
- EQUAL_LENGTH = 14#
- FIX_POINT = 15#
- HORIZONTAL = 16#
- VERTICAL = 17#
- class drawing_tools.DimensionAnalyzer(view: View, tolerance: float = 0.001)#
Bases:
objectFluent 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:
Constraintor 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
- class drawing_tools.EdgeAdjacencyGraph(view: View, tolerance: float = 0.001, include_incident: bool = False)#
Bases:
objectAdjacency 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.
- 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.FeaturedDrawing(drawing: Drawing, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Bases:
DessiaObjectAn enhanced representation of a technical drawing with calculated features.
This class enriches a Drawing object with calculated features that are not directly available in the original Drawing object, including featured sheets, organized annotations, and extracted metadata.
- __init__(drawing: Drawing, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Initialize a FeaturedDrawing instance.
- Parameters:
drawing – The source Drawing 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 drawing object.
This allows accessing drawing attributes (passed as name) directly from FeaturedDrawing, e.g., featured_drawing.sheets instead of featured_drawing.drawing.sheets
- property sheets: list[FeaturedSheet]#
Get all featured sheets in the drawing.
- property views: list[FeaturedView]#
Get all featured views in the drawing.
- views_of_types(view_types: list[ViewType], dominant_language: str | None = None) list[FeaturedView]#
Extract views of specified view types from the drawing.
- Parameters:
view_types – List of ViewType enum values to filter by
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified types across all sheets
- views_of_types_by_reading_order(view_types: list[ViewType], dominant_language: str | None = None) list[FeaturedView]#
Get views of specified view types sorted by reading order in the drawing.
- Parameters:
view_types – List of ViewType enum values to filter by
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified types, sorted by reading order
- property collector: DrawingCollector#
Get the DrawingCollector for accessing drawing-level collectors.
This property provides access to drawing-level filtering and searching operations, consistent with how Sheet.collector and View.collector work in dessia_drawing.
Example
symbols = featured_drawing.collector.type.symbols(entity_subtypes=[“TypeBalloon”]) dimensions = featured_drawing.collector.type.dimensions() text_results = featured_drawing.collector.text.search(“tolerance”)
- Returns:
DrawingCollector instance for the underlying drawing
- plot_data_view_indexes#
Specific display tag for PlotData. Add a picture argument.
- plot_data_grid_reference#
Specific display tag for PlotData. Add a picture argument.
- plot_data_balloons#
Specific display tag for PlotData. Add a picture argument.
- plot_data_section_lines#
Specific display tag for PlotData. Add a picture argument.
- plot_data_balloon_flags#
Specific display tag for PlotData. Add a picture argument.
- plot_data_sets#
Specific display tag for PlotData. Add a picture argument.
- plot_data_tables#
Specific display tag for PlotData. Add a picture argument.
- plot_data_title_view#
Specific display tag for PlotData. Add a picture argument.
- plot_data_auxiliary_view_indicators#
Specific display tag for PlotData. Add a picture argument.
- 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.
- class drawing_tools.FeaturedSheet(sheet: Sheet, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Bases:
DessiaObjectAn enhanced representation of a technical drawing sheet with calculated features.
This class enriches a Sheet object with calculated features that are not directly available in the original Sheet object, including featured views, organized annotations, and extracted metadata.
- __init__(sheet: Sheet, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Initialize a FeaturedSheet instance.
- Parameters:
sheet – The source Sheet 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 sheet object.
This allows accessing sheet attributes (passed as name) directly from FeaturedSheet, e.g., featured_sheet.views instead of featured_sheet.sheet.views
- property views: list[FeaturedView]#
Get all featured views in the sheet.
- get_background_view() View#
Get the background view of the sheet.
- views_of_types(view_types: list[ViewType], dominant_language: str | None = None) list[FeaturedView]#
Get all views of specific types in the sheet.
- Parameters:
view_types – List of ViewType enum values to filter by
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified types
- views_of_type(view_type: ViewType, dominant_language: str | None = None) list[FeaturedView]#
Get all views of a specific type in the sheet.
- Parameters:
view_type – The ViewType enum value to filter by
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified type
- views_of_types_by_reading_order(view_types: list[ViewType], y_tolerance: float = 50.0, dominant_language: str | None = None) list[FeaturedView]#
Get views of specified view types sorted by reading order in the sheet.
- Parameters:
view_types – List of ViewType enum values to filter by
y_tolerance – Y-coordinate tolerance for reading order sorting (default: 50.0)
dominant_language – The language to use for type detection (e.g., “french”, “english”)
- Returns:
List of FeaturedView instances matching the specified types, sorted by reading order
- property collector: SheetCollector#
Get the SheetCollector for accessing sheet-level collectors.
This property provides access to sheet-level filtering and searching operations, consistent with how View.collector works in dessia_drawing.
Example
symbols = featured_sheet.collector.type.symbols(entity_subtypes=[“TypeBalloon”]) views_sorted = featured_sheet.collector.get_views_sorted_by_reading_order() text_results = featured_sheet.collector.text.search(“tolerance”)
- Returns:
SheetCollector instance for the underlying sheet
- property background_view: FeaturedView#
Get the background view of the sheet as a FeaturedView.
- property front_views: list[FeaturedView]#
Get all front views in the sheet.
- property section_views: list[FeaturedView]#
Get all section views in the sheet.
- property isometric_views: list[FeaturedView]#
Get all isometric views in the sheet.
- property detail_views: list[FeaturedView]#
Get all detail views in the sheet.
- property auxiliary_views: list[FeaturedView]#
Get all auxiliary views in the sheet.
- property other_views: list[FeaturedView]#
Get all other views in the sheet.
- property section_line_indicators: list[SectionLineIndicator]#
Get all section line indicators across all views of the sheet.
- property auxiliary_view_indicators: list[tuple[IdentifierInfo, object]]#
Get all auxiliary view indicators across all views of the sheet.
- property sets: list[SheetSet]#
Get detected sheet sets (lazy-cached).
- Returns:
List of SheetSet instances, empty if no sets detected
- property has_sets: bool#
Check if the sheet has detected sets.
- Returns:
True if at least one set was detected
- get_set_for_view(view: FeaturedView) SheetSet | None#
Find which set a view belongs to, based on full bounding rectangle containment.
Views that span multiple sets are not assigned to any set.
- Parameters:
view – The FeaturedView to locate
- Returns:
The containing SheetSet, or None if the view spans multiple sets
- get_views_in_set(sheet_set: SheetSet) list[FeaturedView]#
Get all views fully contained within a given set.
Views spanning multiple sets (or the entire sheet) are excluded.
- Parameters:
sheet_set – The SheetSet to query
- Returns:
List of FeaturedView instances fully within the set
- property views_by_set: dict[str, list[FeaturedView]]#
Get views organized by set name.
- Returns:
Dictionary mapping set names to lists of FeaturedView instances
- plot_data_view_indexes#
Specific display tag for PlotData. Add a picture argument.
- plot_data_grid_reference#
Specific display tag for PlotData. Add a picture argument.
- collect_title_overlay_primitives() list#
Collect title overlay primitives for all views, each in a different color.
- Returns:
List of plot_data primitives (rectangle + text labels per view).
- collect_section_line_overlay_primitives() list#
Collect section line indicator overlay primitives for all views.
- Returns:
List of plot_data primitives (rectangle + text labels per indicator).
- collect_table_overlay_primitives() list#
Collect table overlay primitives for all detected tables in the sheet.
Delegates to
SheetTableDetector.collect_overlay_primitives().- Returns:
List of plot_data primitives (rectangle + text label per table).
- collect_balloon_overlay_primitives() list#
Collect balloon overlay primitives for all views.
Delegates to each view’s
collect_balloon_overlay_primitives()and adds the color legend at the top of the sheet.- Returns:
List of plot_data primitives.
- plot_data_balloons#
Specific display tag for PlotData. Add a picture argument.
- plot_data_section_lines#
Specific display tag for PlotData. Add a picture argument.
- collect_balloon_flags_overlay_primitives() list#
Collect balloon flags overlay primitives (multiplicators, FM symbols) for all views.
- Returns:
List of plot_data primitives.
- plot_data_balloon_flags#
Specific display tag for PlotData. Add a picture argument.
- collect_sets_overlay_primitives() list#
Collect set region overlay primitives for all detected sets.
Delegates to
get_sets_plot_data_primitives()from the sheet sets visualization helper.- Returns:
List of plot_data primitives (colored rectangles + labels per set).
- plot_data_sets#
Specific display tag for PlotData. Add a picture argument.
- plot_data_tables#
Specific display tag for PlotData. Add a picture argument.
- plot_data_title_view#
Specific display tag for PlotData. Add a picture argument.
- collect_auxiliary_view_indicator_overlay_primitives() list#
Collect auxiliary view indicator overlay primitives for all views.
- plot_data_auxiliary_view_indicators#
Specific display tag for PlotData. Add a picture argument.
- collect_all_identifier_overlay_primitives() list#
Collect all identifier overlay primitives for all views.
- 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.
- class drawing_tools.FeaturedView(view: View, language_configs: list[LanguageConfig] | None = None, title_detection_config: TitleDetectionConfig | None = None)#
Bases:
DessiaObjectAn 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 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 section_line_indicators: list[SectionLineIndicator]#
Get all detected section line indicators 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 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
- 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
balloonsto 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_indicatorsto 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.
- class drawing_tools.GeometryDimensionGraph(view: View, tolerance: float = 0.001)#
Bases:
objectGraph 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_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
- class drawing_tools.SheetSet(name: str, bounding_rectangle: BoundingRectangle, symbol: Symbol | None = None)#
Bases:
objectA named rectangular region within a sheet.
- Parameters:
name – The set identifier (e.g., “000”, “001”)
bounding_rectangle – The rectangular boundary of this set
symbol – The SET marker symbol that identifies this set
- bounding_rectangle: BoundingRectangle#
- contains_point(point: Point2D) bool#
Check if a point lies within this set’s bounding rectangle.
- Parameters:
point – The 2D point to check
- Returns:
True if the point is inside the set
- fully_contains_rectangle(rectangle: BoundingRectangle) bool#
Check if a rectangle is fully inside this set’s bounding rectangle.
- Parameters:
rectangle – The rectangle to check
- Returns:
True if the rectangle is entirely contained within the set
- contains_entity(entity: object) bool#
Check if an entity’s center lies within this set.
- Parameters:
entity – An entity with a bounding_rectangle property
- Returns:
True if the entity’s center is inside the set
- plot_data_primitives(fill_color: tuple[float, float, float] = (0.6, 0.8, 1.0), opacity: float = 0.15) list[PlotDataObject]#
Get plot_data primitives visualizing this set region.
- Parameters:
fill_color – RGB tuple in [0, 1] range for the region fill.
opacity – Fill opacity.
- Returns:
List of plot_data primitives.
- class drawing_tools.SheetTableDetector(sheet: Sheet, candidate_preparation_config: CandidatePreparationConfig | None = None, table_generation_config: TableGenerationConfig | None = None, table_selection_config: TableSelectionConfig | None = None, store_detection_data: bool = False)#
Bases:
DessiaObjectDetects and extracts table structures from technical drawing sheets.
- __init__(sheet: Sheet, candidate_preparation_config: CandidatePreparationConfig | None = None, table_generation_config: TableGenerationConfig | None = None, table_selection_config: TableSelectionConfig | None = None, store_detection_data: bool = False)#
Initialize the detector with a sheet.
- Parameters:
sheet – The sheet containing tables.
candidate_preparation_config – Configuration for candidate edge preparation (Phase 1)
table_generation_config – Configuration for table structure detection (Phase 2)
table_selection_config – Configuration for table validation and selection (Phase 3)
store_detection_data – If True, store all intermediate pipeline data for visualization/debugging. Access via
detection_dataproperty after detection.
- property tables: dict[int, list[Table | DetectedTable]]#
All detected tables (computed once on first access).
- Returns:
Dictionary mapping view index to list of detected tables.
- property detection_data: TableDetectionData#
Access stored detection data. Only available when
store_detection_data=True.
- get_title_block_annotations() list[Entity]#
Extract annotations that belong to the title block area.
- get_title_block_table() DetectedTable | None#
Detect the table that represents the title block in the drawing.
- detect_title_block() TitleBlock | None#
Detect the title block and extract structured information.
- detect_view_tables(view: View, is_background: bool = False, _view_index: int | None = None) list[Table | DetectedTable]#
Detect tables in a specific view.
This method finds tables in the view through three independent branches: 1. tables_from_tables — existing Table annotation instances 2. tables_from_notes — Symbol entities (TypeNote) with a rectangular frame 3. tables_from_geometries — edge-based detection from view geometries
- Parameters:
view – The view to search for tables in
is_background – Whether this is the background view (affects detection strategy)
_view_index – Optional view index for storing intermediate data
- Returns:
List of detected table objects (mix of Table annotations and DetectedTable instances)
- detect_tables_in_background_view() list[Table | DetectedTable]#
Detect tables specifically in the background view.
This is a convenience method that calls detect_view_tables with the background view and appropriate settings for background view processing.
- Returns:
List of detected table objects in the background view
- detect_all_tables() dict[int, list[Table | DetectedTable]]#
Detect all tables in the drawing across all views.
This method processes each view to find tables in three ways: 1. Direct inclusion of existing Table instances from annotations 2. For regular views: Detection from view geometries and annotations 3. For all views: Detection within CompositeEntity objects
The background view is treated specially - only CompositeEntity objects and existing Table instances are processed since tables there are typically pre-structured.
Tables are validated to ensure they have sufficient content before being included.
- Returns:
Dictionary mapping view index to list of validated detected tables
- class drawing_tools.TableCell(row_id: int, col_id: int, start: Point2D, end: Point2D, row_range: tuple[int, int], col_range: tuple[int, int], content: list[Entity] | None = None, name: str = '')#
Bases:
DessiaObjectRepresents a logical cell in a detected table with content.
TableCell represents the logical/semantic cells of a table, which may span multiple grid positions when merged. Each TableCell contains the actual content (text, annotations) and represents how the table appears to users.
- Example:
If a table cell spans positions (0,0) to (0,2) in the grid: - get_table_cell_at(0, 0), get_table_cell_at(0, 1), get_table_cell_at(0, 2) all return the same TableCell - This TableCell has row_range=(0,0), col_range=(0,2) and contains all content
- __init__(row_id: int, col_id: int, start: Point2D, end: Point2D, row_range: tuple[int, int], col_range: tuple[int, int], content: list[Entity] | None = None, name: str = '')#
Initialize a TableCell.
- Parameters:
row_id – Row index of the first grid position this cell occupies
col_id – Column index of the first grid position this cell occupies
start – Bottom-left corner point of the cell
end – Top-right corner point of the cell
row_range – Tuple of (start_row, end_row) indicating the cell’s row span
col_range – Tuple of (start_col, end_col) indicating the cell’s column span
content – Optional list of Entity objects (text, annotations) contained in this cell
name – Optional name for the cell
- property center: Point2D#
Get the center point of the cell.
- property bounding_rectangle: BoundingRectangle#
Convert cell to a BoundingRectangle.
- contains_entity(entity: Entity) bool#
Check if an entity belongs to this cell.
An entity belongs to a cell if its bounding rectangle center is inside the cell’s bounding rectangle.
- Parameters:
entity – The entity to check
- Returns:
True if the entity belongs to this cell
- add_content(entity: Entity) None#
Add an entity to this cell’s content.
- Parameters:
entity – The entity to add to the cell
- get_text_content(ordered: bool = True, line_tolerance: float = 2.0) list[str]#
Extract text content from all entities in this cell.
- Parameters:
ordered – If True, orders content in reading order (top-to-bottom, left-to-right)
line_tolerance – Tolerance for grouping items on the same line (in drawing units)
- Returns:
List of text strings from text-searchable entities
- get_ordered_content(line_tolerance: float = 2.0) list[Entity]#
Get cell content ordered in reading order (top-to-bottom, left-to-right).
Groups entities by line (similar Y coordinate) then sorts each line left-to-right.
- Parameters:
line_tolerance – Tolerance for grouping items on the same line
- Returns:
List of entities ordered for reading
- get_combined_text(ordered: bool = True, separator: str = ' ', line_tolerance: float = 2.0) str#
Get all text content combined into a single string.
- Parameters:
ordered – If True, orders content in reading order
separator – Separator between text elements
line_tolerance – Tolerance for grouping items on the same line
- Returns:
Combined text string
- contains_text(text: str, case_sensitive: bool = False, ordered: bool = True) bool#
Check if this cell contains the given text.
Searches through the cell’s combined text content and returns True if the specified text is found as a substring.
- Parameters:
text – The text to search for (e.g., “SAFETY CLASS”)
case_sensitive – If True, the search is case-sensitive (default: False)
ordered – If True, orders content in reading order before searching
- Returns:
True if the cell contains the text, False otherwise
- class drawing_tools.TableLine(edge: Edge | None = None, start: Point2D | None = None, end: Point2D | None = None, tolerance: float = 0.5, span_ranges: list[tuple[float, float]] | None = None, name: str = '')#
Bases:
DessiaObjectRepresents a line segment for table detection, either from an Edge or virtual.
This class wraps line segments that are used in table structure detection, providing convenient properties for analyzing table grid patterns. Lines can be either extracted from Edge objects or created as virtual lines to complete table boundaries.
- __init__(edge: Edge | None = None, start: Point2D | None = None, end: Point2D | None = None, tolerance: float = 0.5, span_ranges: list[tuple[float, float]] | None = None, name: str = '')#
Initialize either from an Edge or from explicit coordinates.
- Parameters:
edge – Optional Edge object to extract line from
start – Start point (required if edge is None)
end – End point (required if edge is None)
tolerance – Tolerance for line classification (vertical/horizontal detection)
span_ranges – Optional custom span ranges (for merged lines with gaps)
- Raises:
ValueError – If edge is invalid or if start/end are missing when edge is None
- classmethod from_edge(edge: Edge, tolerance: float = 0.001) TableLine#
Create TableLine from an Edge object.
- Parameters:
edge – Edge containing a line segment
tolerance – Tolerance for line classification
- Returns:
TableLine instance
- classmethod virtual(start: Point2D, end: Point2D, tolerance: float = 0.001) TableLine#
Create a virtual TableLine without an associated Edge.
Virtual lines are used to complete table boundaries when detecting table structures that may have incomplete borders.
- Parameters:
start – Start point of the line
end – End point of the line
tolerance – Tolerance for line classification
- Returns:
TableLine instance marked as virtual
- property start: Point2D#
Get the start point of the line segment.
- property end: Point2D#
Get the end point of the line segment.
- property line_coordinate: float#
Get the coordinate value where this line is positioned.
For vertical lines, returns the x-coordinate. For horizontal lines, returns the y-coordinate.
- Returns:
The average coordinate along the line’s perpendicular axis
- property is_virtual: bool#
Check if this is a virtual line (no associated Edge).
Virtual lines are created to complete table boundaries and don’t correspond to actual geometry in the drawing.
- Returns:
True if this line has no associated Edge object
- merge_with(other: TableLine) TableLine#
Merge this line with another parallel line.
- Parameters:
other – Another TableLine that should be parallel to this one
- Returns:
New TableLine representing the merged result
- Raises:
ValueError – If lines are not parallel or compatible
- property gap_positions: list[tuple[float, float]]#
Get the positions of gaps in this line.
- Returns:
List of (start, end) positions where gaps exist
- property coverage_ratio: float#
Calculate the ratio of covered length to total possible length.
Useful for determining if a line is mostly continuous or has significant gaps.
- is_on_range(coord: float, tolerance: float = 0.0) bool#
Check if a coordinate falls on any span of this line.
- Parameters:
coord – y-coordinate for vertical lines, x-coordinate for horizontal
tolerance – Tolerance to extend span boundaries (handles floating-point imprecision)
- Returns:
True if the coordinate is within any span range
- class drawing_tools.TableStructure(lines: list[TableLine], bounds: BoundingRectangle, tolerance: float = 0.001, name: str = '')#
Bases:
DessiaObjectRepresents the reverse-engineered structure of a table.
Contains organized lines, grid information, and methods to detect cells within the structure. Serves as the structural foundation for creating a DetectedTable.
- __init__(lines: list[TableLine], bounds: BoundingRectangle, tolerance: float = 0.001, name: str = '')#
Initialize by extracting structure from lines.
- Parameters:
lines – Collection of TableLine objects
bounds – Bounding rectangle of the structure
tolerance – Tolerance for line processing
- detect_cells(min_cell_size: float = 2.0, annotations: list[Entity] | None = None) list[TableCell]#
Detect TableCell objects by analyzing the grid structure and optionally populate with annotations.
- Parameters:
min_cell_size – Minimum dimension for a valid cell
annotations – Optional list of annotations to associate with cells
- Returns:
List of detected TableCell objects with their content
- class drawing_tools.TitleBlock(legal_owner: str, identification_number: str, date_of_issue: str, title: str, page_number: int = 1, part_ids: list[str] | None = None, revision: str | None = None, number_of_pages: int | None = None, material: str | None = None, weight: str | None = None, general_tolerances: str | None = None, surface_roughness: str | None = None, creator: str | None = None, approver: str | None = None, scale: str | None = None, projection_method: str | None = None, drawing_size: str | None = None, status: str | None = None, zone: str | None = None, safety_class: str | None = None, ecr_ecp_eco: str | None = None, protection_standard: str | None = None, parent_table: DetectedTable | None = None, name: str = '')#
Bases:
DessiaObjectMain title block container following ISO 7200:2004.
- __init__(legal_owner: str, identification_number: str, date_of_issue: str, title: str, page_number: int = 1, part_ids: list[str] | None = None, revision: str | None = None, number_of_pages: int | None = None, material: str | None = None, weight: str | None = None, general_tolerances: str | None = None, surface_roughness: str | None = None, creator: str | None = None, approver: str | None = None, scale: str | None = None, projection_method: str | None = None, drawing_size: str | None = None, status: str | None = None, zone: str | None = None, safety_class: str | None = None, ecr_ecp_eco: str | None = None, protection_standard: str | None = None, parent_table: DetectedTable | None = None, name: str = '')#
Initialize title block with extracted information.
- Parameters:
legal_owner – The name of the company or individual that owns the drawing’s copyright and content. Corresponds to ISO 7200 field ‘a’.
identification_number – The primary, unique identifier for the drawing, such as a part or drawing number. Corresponds to ISO 7200 field ‘b’.
date_of_issue – The date when this version of the drawing was officially issued or released, preferably in YYYY-MM-DD format. Corresponds to ISO 7200 field ‘f’.
title – The descriptive title of the drawing’s subject. This typically describes the part, assembly, or system shown. Corresponds to ISO 7200 field ‘d’.
page_number – The number of the current sheet. Defaults to 1. Corresponds to ISO 7200 field ‘g’.
part_ids – A list of any additional identification numbers associated with the drawing.
revision – The revision identifier (e.g., ‘A’, ‘B’, ‘1.0’) indicating the version of the drawing. Corresponds to ISO 7200 field ‘c’.
number_of_pages – The total number of sheets in the complete drawing set. Corresponds to ISO 7200 field ‘h’.
material – The material specification for the part shown in the drawing (e.g., ‘EN_10027 - S235JR’).
weight – The mass of the object depicted in the drawing, including units (e.g., ‘0,04 kg’).
general_tolerances – The standard for general tolerances to be applied unless otherwise specified (e.g., ‘ISO 2768-mK’).
surface_roughness – The standard or default requirement for surface texture.
creator – The name of the person who created or drew the drawing. Corresponds to ISO 7200 field ‘e’ (Drawn by).
modified_by – The name of the person who last modified the drawing.
approver – The name of the person who approved the drawing for release.
scale – The primary scale of the drawing (e.g., ‘1:1’, ‘1:2’).
projection_method – The projection method used (e.g., ‘First angle’, ‘Third angle’), often represented by the ISO projection symbol.
drawing_size – The size of the drawing sheet according to ISO 5457 (e.g., ‘A3’, ‘A4’).
status – The current lifecycle status of the drawing (e.g., ‘In work’, ‘Released’, ‘Obsolete’).
zone – A reference to a specific zone on the drawing grid.
safety_class – Any safety classification applicable to the part or drawing.
ecr_ecp_eco – Engineering Change Request/Proposal/Order number associated with this drawing version.
protection_standard – The standard for any protective treatment or coating.
parent_table – A reference to the DetectedTable object from which this title block was extracted.
extraction_timestamp – The ISO-formatted timestamp of when the extraction was performed.
name – An optional name for the TitleBlock instance.
- class drawing_tools.ViewDimensionAnalysis(view: View, tolerance: float = 0.001)#
Bases:
objectView-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
- class drawing_tools.ViewTitle(source_entity: Entity, language_configs: list[LanguageConfig], name: str = '')#
Bases:
DessiaObjectA 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 parsed_result: TitleParsedResult#
Get parsed semantic information from the title using TitleParser.
- property view_type_by_language: dict[str, ViewTypeInfo]#
Get view types 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.
- report#
Implementation of a tag for displays.
- 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.
- drawing_tools.detect_sets_by_subdivision_lines(sheet: Sheet, min_length_ratio: float = 0.8) list[SheetSet]#
Detect sheet sets by finding subdivision lines and SET marker symbols.
Algorithm: 1. Get the background view’s content zone and content geometries 2. Find subdivision lines (line segments spanning ~full content width or height) 3. Split the content zone into candidate rectangular regions 4. Validate each region contains a Symbol with frame.entity_type == “SET” 5. Name each set from the symbol’s text content
- Parameters:
sheet – The sheet to analyze
min_length_ratio – Minimum fraction of the content dimension a line must span to be considered a subdivision line (0.8 = at least 80%)
- Returns:
List of detected SheetSet instances