Engineering Rules Examples#
This section provides an overview of engineering rules verification examples using Drawing Tools. These examples demonstrate how to implement automated checks for technical drawing compliance.
The implementation scripts are located in scripts/rules_examples/ in the repository.
Common Pattern#
Most rule implementations follow a two-step pattern:
Data Preparation (
r*_prepare_data.py): Load drawing and prepare dataRule Computation (
r*_compute_rule.py): Apply verification logic and report results
All rules use FeaturedDrawing to wrap a Drawing object with language configurations,
then leverage view filtering methods (views_of_types, views_of_types_by_reading_order)
and title parsing (view.title.identifiers_by_language, view.title.view_name_by_language).
When relevant, non-compliant entities or views are highlighted on the drawing using
set_bounding_box_highlight() and the result is exported to HTML via sheet.plot_data().
Rule 1.1: Callout Validation#
Validates that callouts (balloons, NOTA text, protection codes) in the drawing match the locations specified in the Bill of Materials (BOM) “DRW Loc.” column.
Main elements used:
featured_drawing.collector.type.symbols(entity_subtypes=["TypeBalloon"])to collect calloutsGrid coordinate calculation from callout positions
BOM parsing for expected locations
Scripts: scripts/rules_examples/r11_callout_locations/
Rule 2.1: View Name Uniqueness#
Verifies that view names are unique within the entire drawing.
Main elements used:
featured_drawing.views_of_types()to get all viewsidentify_duplicate_in_list()utility functionview.namefor comparison
Scripts: scripts/rules_examples/r21_views_names_unicity_in_sheet/
Rule 2.2: View Number Equals Page Number#
Validates that view identifiers include the correct sheet number as suffix (e.g., “A2” for sheet 2, “B3” for sheet 3).
Main elements used:
view.title.identifiers_by_language[language].numberfor identifier numberview.sheet_indexfor sheet number comparison
Scripts: scripts/rules_examples/r22_views_number_equals_page_number/
Rule 2.3: Views Order in Sheet#
Validates that detail, section, and auxiliary views follow alphabetical order within each sheet. The alphabetical counter resets for each sheet.
Main elements used:
sheet.views_of_types_by_reading_order()to get views sorted by positionview.title.identifiers_by_language[language].letterfor letter extractionget_supposed_letters_list()andget_forbidden_letters_for_view_types()utility functions
Scripts: scripts/rules_examples/r23_views_order_in_sheet/
Rule 2.31: Section Views Order in Drawing#
Validates that section views follow alphabetical order across the entire drawing (without resetting between sheets).
Main elements used:
Same as Rule 2.3 but applied across all sheets continuously
Scripts: scripts/rules_examples/r231_views_order_in_drawing/
Rule 2.32: Detail Views Order in Drawing#
Same principle as Rule 2.31 but for detail views only.
Scripts: scripts/rules_examples/r232_detail_views_order_in_drawing/
Rule 2.33: Auxiliary Views Order in Drawing#
Same principle as Rule 2.31 but for auxiliary views only.
Scripts: scripts/rules_examples/r233_auxiliary_views_order_in_drawing/
Rule 2.5: Forbidden View Letters#
Validates that view identifiers do not use forbidden letters (e.g., I, O, Q which can be confused with numbers).
Main elements used:
get_forbidden_letters_for_view_types()to get forbidden lettersview.title.identifiers_by_language[language].letterfor validation
Scripts: scripts/rules_examples/r25_forbidden_view_letters/
Rule 2.7: View Labels Validity#
Validates that view labels (COUPE, DETAIL, VUE DE FACE…) match valid keywords defined in the language configuration.
Main elements used:
view.title.identifiers_by_language[language].labelfor label extractionDEFAULT_FRENCH_CONFIG.view_type_identification_keywordsfor valid labels
Scripts: scripts/rules_examples/r27_view_labels_validity/
Rule 2.8: Title Format#
Validates that view titles use the correct font style, font name, and font size according to sheet format and language specifications.
Main elements used:
view.title.view_name_by_language[language].text_linefor text accesstext_line.text_style_extractor.dominant_text_stylefor font propertiesfeatured_sheet.formatfor sheet format
Scripts: scripts/rules_examples/r28_titles_styles_and_format/