f6cd91f1b5
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
33 lines
1.3 KiB
Markdown
33 lines
1.3 KiB
Markdown
# 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 `ExportRecords` table (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:
|
|
|
|
1. Query the DB for the most recent `ExportRecord` where `SourceFilePath` matches `activeDoc.FilePath` (case-insensitive)
|
|
2. If found, parse the stored `DrawingNumber` via `DrawingInfo.Parse()` and auto-fill equipment/drawing dropdowns
|
|
3. 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)
|