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:

  1. Data Preparation (r*_prepare_data.py): Load drawing and prepare data

  2. Rule 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 callouts

  • Grid 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 views

  • identify_duplicate_in_list() utility function

  • view.name for 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].number for identifier number

  • view.sheet_index for 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 position

  • view.title.identifiers_by_language[language].letter for letter extraction

  • get_supposed_letters_list() and get_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 letters

  • view.title.identifiers_by_language[language].letter for 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].label for label extraction

  • DEFAULT_FRENCH_CONFIG.view_type_identification_keywords for 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_line for text access

  • text_line.text_style_extractor.dominant_text_style for font properties

  • featured_sheet.format for sheet format

Scripts: scripts/rules_examples/r28_titles_styles_and_format/