diff --git a/README.md b/README.md index 28aede1..02b35a6 100644 --- a/README.md +++ b/README.md @@ -12,22 +12,25 @@ The first target is **AutoCAD 2020**, using **C# / .NET Framework / WPF**. - Review and edit recognized values before import - Create AutoCAD `DBPoint` objects - Add point-number `DBText` labels next to points -- Export recognized coordinates to CSV +- Export coordinates to CSV No latitude/longitude or coordinate-system transformation is planned for the first MVP. -## Current development build +## Current development build — v0.2 -The bootstrap build already contains: +The current development branch contains: -- AutoCAD plugin entry point - `OCR2GEOMETRY` command -- WPF plugin window -- test coordinate model +- editable X/Y coordinate table +- add and delete table rows +- X/Y swap +- configurable start point number +- configurable text height - creation of `DBPoint` objects in Model Space - creation of point-number `DBText` labels +- CSV export with `Point,X,Y` columns -Test coordinates currently used by the bootstrap build: +Three sample coordinates are preloaded for quick testing: ```text 1 512345.23 6876543.11 @@ -39,7 +42,7 @@ Test coordinates currently used by the bootstrap build: - Windows - AutoCAD 2020 installed -- Visual Studio 2022 with .NET desktop development tools +- Visual Studio with .NET desktop development tools - .NET Framework 4.7.2 targeting pack The project expects the AutoCAD managed API assemblies in the default installation directory: @@ -59,29 +62,21 @@ AutoCAD references use `Copy Local = False` so Autodesk DLLs are not copied into 1. Open `OCR2Geometry.sln` in Visual Studio. 2. Build the solution in `Debug` or `Release` mode. 3. Start AutoCAD 2020. -4. Run: - -```text -NETLOAD -``` - +4. Run `NETLOAD`. 5. Select the built `OCR2Geometry.dll`, normally from: ```text src\OCR2Geometry\bin\Debug\OCR2Geometry.dll ``` -6. Run: - -```text -OCR2GEOMETRY -``` +6. Run `OCR2GEOMETRY`. +7. Edit/add/delete coordinate rows as required. +8. Test `Swap X/Y`. +9. Set a start number and text height. +10. Click **Create points** and verify points/labels in Model Space. +11. Click **Export CSV** and verify the saved coordinate table. -7. Click **Create test points**. - -The bootstrap build should create three points and their point numbers in Model Space. - -## Planned development stages +## Development stages ### v0.1 — AutoCAD bootstrap @@ -90,26 +85,32 @@ The bootstrap build should create three points and their point numbers in Model - [x] WPF window - [x] Test point creation - [x] Point numbering labels +- [x] Validated in AutoCAD 2020 -### v0.2 — Coordinate table - -- [ ] Editable coordinate grid -- [ ] Add/delete rows -- [ ] Start-number setting -- [ ] Text height and text offset settings -- [ ] X/Y swap +### v0.2 — Coordinate workflow -### v0.3 — CSV +- [x] Editable coordinate grid +- [x] Add/delete rows +- [x] Start-number setting +- [x] Text-height setting +- [x] X/Y swap +- [x] Create points from the edited table +- [x] CSV export +- [ ] Validate v0.2 build in AutoCAD 2020 -- [ ] Export recognized/edited table to CSV - -### v0.4 — OCR +### v0.3 — OCR foundation - [ ] Image selection - [ ] OCR engine integration - [ ] Coordinate table parser - [ ] Recognition confidence / validation workflow +### Later improvements + +- [ ] User-defined text offset +- [ ] Improved AutoCAD layer/settings workflow +- [ ] Support additional AutoCAD versions + ## Project structure ```text @@ -119,6 +120,7 @@ OCR2Geometry-for-AutoCAD/ │ └── OCR2Geometry/ │ ├── AutoCAD/ │ ├── Commands/ +│ ├── Export/ │ ├── Models/ │ ├── Properties/ │ ├── UI/ @@ -128,4 +130,4 @@ OCR2Geometry-for-AutoCAD/ ## Status -Early development. The current branch is intended to prove the AutoCAD 2020 plugin loading and geometry-writing workflow before OCR is added. +Active development. v0.1 has been validated in AutoCAD 2020; v0.2 is ready for local build/testing before merge to `main`. diff --git a/src/OCR2Geometry/Export/CsvExporter.cs b/src/OCR2Geometry/Export/CsvExporter.cs new file mode 100644 index 0000000..a62914f --- /dev/null +++ b/src/OCR2Geometry/Export/CsvExporter.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Globalization; +using System.IO; +using System.Text; +using OCR2Geometry.Models; + +namespace OCR2Geometry.Export +{ + public static class CsvExporter + { + public static void Export(string path, IEnumerable points) + { + using (var writer = new StreamWriter(path, false, new UTF8Encoding(true))) + { + writer.WriteLine("Point,X,Y"); + + foreach (var point in points) + { + writer.WriteLine(string.Format( + CultureInfo.InvariantCulture, + "{0},{1:0.########},{2:0.########}", + point.Number, + point.X, + point.Y)); + } + } + } + } +} diff --git a/src/OCR2Geometry/OCR2Geometry.csproj b/src/OCR2Geometry/OCR2Geometry.csproj index 2974df8..461b8b8 100644 --- a/src/OCR2Geometry/OCR2Geometry.csproj +++ b/src/OCR2Geometry/OCR2Geometry.csproj @@ -56,6 +56,7 @@ + MainWindow.xaml diff --git a/src/OCR2Geometry/UI/MainWindow.xaml b/src/OCR2Geometry/UI/MainWindow.xaml index 1cc79fe..b6f693b 100644 --- a/src/OCR2Geometry/UI/MainWindow.xaml +++ b/src/OCR2Geometry/UI/MainWindow.xaml @@ -2,9 +2,10 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="OCR2Geometry for AutoCAD" - Height="360" - Width="560" - ResizeMode="CanMinimize" + Height="560" + Width="760" + MinHeight="500" + MinWidth="700" WindowStartupLocation="CenterOwner"> @@ -12,6 +13,7 @@ + - - - - - - - - - - - -