drawing_tools.config package#
Submodules#
drawing_tools.config.view_language_configs module#
Language configuration for technical drawing title parsing.
This module provides language-specific configurations for parsing technical drawing titles, including patterns for scales, repetitions, and view names.
- class drawing_tools.config.view_language_configs.ViewTypePatterns(patterns_by_type: dict[str, list[str]])#
Bases:
DessiaObjectOrdered mapping of ViewType values to regex patterns for view name detection.
Each key is a ViewType string value (e.g., “section_view”, “front_view”). Each value is an ordered list of regex pattern strings, from most specific to most general. The first matching pattern wins for a given view type; if matched, no other view types are tested for that text line.
Order of keys matters: more specific view types must come before general ones (e.g., “typ_section_view” before “section_view”, “rotated_view_on” before “auxiliary_view”) to avoid false matches on the general type.
Patterns may include named groups such as
section_line,identifier,letter,number,cross_reference_left,cross_reference_rightto extract view identifiers and cross-references in the same pass. Seedefault_language_configs.pyfor examples of pattern composition using the building-block constants from this module.- Parameters:
patterns_by_type – Dictionary mapping ViewType string values to ordered lists of regex pattern strings.
- class drawing_tools.config.view_language_configs.LanguageConfig(name: str, code: str, scale_patterns: list[str], numeric_repetition_patterns: list[str], word_repetition_patterns: list[str], view_type_patterns: ViewTypePatterns | None = None, word_to_number: dict[str, int] | None = None, custom_fields: dict | None = None)#
Bases:
DessiaObjectConfiguration for language-specific parsing patterns in technical drawing titles.
This dataclass encapsulates all the patterns and keywords needed to parse technical drawing title information (scales, repetitions, view names) for a specific language. It follows ISO standards for technical drawings and supports common patterns found in engineering documentation.
- Parameters:
name – Human-readable language name (e.g., ‘french’, ‘english’). Used as a key for organizing results by language.
code – ISO 639-1 two-letter language code (e.g., ‘fr’, ‘en’).
scale_patterns – Regex pattern strings for detecting scale information. Patterns should be ordered from most specific to most general. Compiled with re.IGNORECASE via the compiled_scale_patterns property. Examples: “SCALE: 2:1”, “1:1”
numeric_repetition_patterns – Regex pattern strings for detecting numeric repetitions. Used when repetition count is expressed as digits. Compiled with re.IGNORECASE via the compiled_numeric_repetition_patterns property. Examples: “VALID 2 TIMES”, “2x”
word_repetition_patterns – Regex pattern strings for detecting repetitions expressed as words. Must be used with word_to_number mapping. Compiled with re.IGNORECASE via the compiled_word_repetition_patterns property. Examples: “VALID TWICE”, “VALABLE DEUX FOIS”
view_type_patterns – A ViewTypePatterns instance defining the patterns for detecting view names and types. See ViewTypePatterns for details.
word_to_number – Mapping of number words to integers for the specific language. Used with word_repetition_patterns. Keys should be lowercase. Default: empty dict. Example: {“one”: 1, “two”: 2, “twice”: 2}
custom_fields – Dictionary for storing arbitrary user-defined fields. Allows extending the configuration without modifying the class. Default: empty dict.
- __init__(name: str, code: str, scale_patterns: list[str], numeric_repetition_patterns: list[str], word_repetition_patterns: list[str], view_type_patterns: ViewTypePatterns | None = None, word_to_number: dict[str, int] | None = None, custom_fields: dict | None = None)#
Initialize a LanguageConfig with parsing patterns and keywords for a specific language.
- property compiled_scale_patterns: list[Pattern]#
Compile scale_patterns strings into re.Pattern objects with re.IGNORECASE.
drawing_tools.config.view_types_config module#
View types configuration for technical drawing views.
This module defines all possible view types that can be identified from view titles in technical drawings.
- class drawing_tools.config.view_types_config.ViewType(*values)#
Bases:
EnumEnumeration of possible view types in technical drawings.
This enum defines all valid view types that can be identified from view titles. Values are used as keys in ViewTypePatterns instances.
Each member carries two extra attributes beyond its string value:
can_have_identifiers: whether the view type can carry identifiers (letter, number, section line). E.g. SECTION_VIEW can (COUPE A2-A2), while FRONT_VIEW cannot.forbidden_letters: list of uppercase letters that must not be used as identifiers for this view type, or None if identifiers are not applicable.
- BACKGROUND_VIEW = 'background_view'#
- FRONT_VIEW = 'front_view'#
- SECTION_VIEW = 'section_view'#
- ISOMETRIC_VIEW = 'isometric_view'#
- DETAIL_VIEW = 'detail_view'#
- AUXILIARY_VIEW = 'auxiliary_view'#
- UNFOLDED_VIEW = 'unfolded_view'#
- EXPLODED_VIEW = 'exploded_view'#
- LHS_VIEW = 'lhs_view'#
- RHS_VIEW = 'rhs_view'#
- BOTTOM_VIEW = 'bottom_view'#
- REAR_VIEW = 'rear_view'#
- TOP_VIEW = 'top_view'#
- LEVELED_SECTION_VIEW = 'leveled_section_view'#
- ROTATED_VIEW_ON = 'rotated_view_on'#
- TYP_SECTION_VIEW = 'typ_section_view'#
- SECTION_CUT = 'section_cut'#
- TYP_SECTION_CUT = 'typ_section_cut'#
Module contents#
Configuration modules for drawing_tools.