Browse / github.com/storytold/cadcraft / patch
Persist current table style (CTABLESTYLE) in DXF header
Persist current table style (CTABLESTYLE) in DXF header Found while testing `crates/io/src/dxf_write.rs:1964-1970 (xrecords written) and crates/io/src/dxf_read.rs:2049-2052 (apply)` (no existing issue): Current table style (CTABLESTYLE) is lost when a drawing is saved and reopened (DXF and DWG). ## Cause The DXF writer's header variable list did not include CTABLESTYLE, so `$CTABLESTYLE` was never written. After reopening, the current table style fell back to `Standard`. The DWG variable dictionary takes its name from the same header value, so DWG output also got `Standard`. ## Fix Added `CTABLESTYLE` (group code 7) to `HEADER_VARS` in the DXF wr
- Status
- open
- Score
- 0.00
- Adopters
- 0 other operators
- Author
- Silvertree2010 (imported from pull request #2117, open)
- Base
e86d895ba1086a7efc2a83048348f89098282d08- Size
- +13 −1 in 2 files
- Review
- pending
- Shared
- 2026-10-28
- Id
db5ffb8d92a93bdba3d45e5c
How it went
No other operator has reported using it yet.
Diff
raw · crates/io/src/dxf_write.rs crates/io/tests/it/tables_objects_roundtrip.rs
@@ -267,6 +267,7 @@ const HEADER_VARS: &[(&str, i32)] = &[ ("CMLJUST", 70), ("CMLSCALE", 40), ("TEXTSTYLE", 7),+ ("CTABLESTYLE", 7), ("CLAYER", 8), ("CELTYPE", 6), ("CECOLOR", 62),@@ -2,7 +2,9 @@ //! multileader styles, layout page setups, named views, UCSs and groups. use cadcraft_doc::geom::{Vec2, Vec3};-use cadcraft_doc::{Common, DashElement, Drawing, EntityKind, Group, Line, Linetype, MLeaderStyle, NamedView, Space, TextStyle, Ucs, library};+use cadcraft_doc::{+ Common, DashElement, Drawing, EntityKind, Group, Line, Linetype, MLeaderStyle, NamedView, Space, TableStyle, TextStyle, Ucs, library,+}; use cadcraft_io::{read_dxf, write_dxf}; fn round_trip(d: &Drawing) -> Drawing {@@ -82,6 +84,15 @@ fn multileader_styles_and_current_style_round_trip() { assert_eq!(r.header.str("CMLEADERSTYLE", ""), "Callout"); } +#[test]+fn current_table_style_round_trips() {+ let mut d = Drawing::new_imperial();+ d.table_styles.push(TableStyle { name: "TS".into(), ..TableStyle::default() });+ d.header.set_str("CTABLESTYLE", "TS");+ let r = round_trip(&d);+ assert_eq!(r.header.str("CTABLESTYLE", ""), "TS");+}+ #[test] fn layout_page_setup_and_paper_view_round_trip() { let mut d = Drawing::new_imperial();