f6cd91f1b5
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1.3 KiB
1.3 KiB
Auto-fill Equipment/Drawing from Export History
Problem
When a SolidWorks file is opened that doesn't match the DrawingInfo regex (e.g., Conveyor Frame.sldasm instead of 5028 A02 Conveyor.slddrw), the equipment and drawing number dropdowns are left empty even though the file may have been exported before with known values.
Decision
- Lookup key: SolidWorks source file path (
ActiveDocument.FilePath) - Storage: Query the existing
ExportRecordstable (no new table or migration) - Priority: Database lookup first; fall back to title regex parse if no history found
Design
Modify UpdateActiveDocumentDisplay() in MainForm.cs
When the active document changes:
- Query the DB for the most recent
ExportRecordwhereSourceFilePathmatchesactiveDoc.FilePath(case-insensitive) - If found, parse the stored
DrawingNumberviaDrawingInfo.Parse()and auto-fill equipment/drawing dropdowns - If not found, fall back to current behavior:
DrawingInfo.Parse(activeDoc.Title)
What doesn't change
- No schema changes, no new migration
- Equipment/drawing dropdowns still populated with historical values in
InitializeDrawingDropdowns() - Export flow untouched
Error handling
- DB query wrapped in try/catch so failures don't break the UI
- Case-insensitive path comparison (Windows paths are case-insensitive)