feat(io): preserve source DWG version for files with version-locked data

Civil3D/AEC objects (and raw MLEADER/Surface records, EED) can only be
written losslessly in their source DWG version. On save, fall back to the
source version when the chosen version is an incompatible encoding family
(acadrust CadDocument::has_version_locked_data), with a command-line
notice, across every save path (Save, Save As, save-before-close/quit)
via a shared dwg_save_version helper. Default the Save-As format dropdown
to the loaded file's version so a round-trip preserves it.

Picks up acadrust DWG-writer conformance fixes (3dbae05) so a Civil3D
R2004 drawing round-trips through OCS and opens in AutoCAD with no errors.

Co-Authored-By: Claude Opus 4.8 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 4.8 committed 2026-06-28 02:46:13 +03:00
1 parent 12f4264183
commit d1efa4ea7c
4 files changed
+92 -4

No files matched your search

+19
View File
@@ -423,6 +423,25 @@ pub fn parse_save_format(format: &str) -> (&'static str, acadrust::DxfVersion) {
(ext, version)
}
/// Reverse of [`parse_save_format`]: the Save-dialog format string for a
/// version + DXF/DWG choice (e.g. `AC1018, is_dxf=false` -> `"DWG 2004"`).
/// Used to default the Save-As dropdown to the loaded file's version so a
/// round-trip preserves it instead of silently offering "DWG 2018".
pub fn format_for_version(version: acadrust::DxfVersion, is_dxf: bool) -> String {
use acadrust::DxfVersion::*;
let year = match version {
AC1032 => "2018",
AC1027 => "2013",
AC1024 => "2010",
AC1021 => "2007",
AC1018 => "2004",
AC1015 => "2000",
AC1014 => "R14",
_ => "2018",
};
format!("{} {}", if is_dxf { "DXF" } else { "DWG" }, year)
}
// ── Plot Style Table ──────────────────────────────────────────────────────
/// Show a file-open dialog and load the selected CTB or STB file.