feat(props): make dim-line colour editable for leaders and dimensions
The "Dim line color" row on Leader and Dimension entities was read-only: an earlier attempt wired it to Leader.override_color, which acadrust never serialises, so the pick was lost on save. Store it instead as a standard ACAD_DSTYLE per-object dimension-style override (DXF code 176, an ACI index) through the existing dim_override codec, so it round-trips through both DWG and DXF like the other dim overrides. RGB picks collapse to the nearest ACI, matching the rest of the dim-colour stack (dimension styles are index-only through the file layer). The renderer prefers the override over the style's DIMCLRD. The write branch is guarded to leaders and dimensions so a mixed selection cannot stamp the override onto other entity types. Bumps acadrust to c9fe982, which carries parsed XDATA onto dimensions on DXF read (it was dropping common.extended_data), so the dimension override persists on DXF save as well as DWG. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
04bd49c715
commit
d005cc4ab1
8 changed files with 241 additions and 29 deletions
|
|
@ -6,6 +6,7 @@
|
|||
//! renderer and the properties panel prefer an override over the style default,
|
||||
//! so editing one of these rows writes here and the change round-trips to file.
|
||||
|
||||
use acadrust::types::Color;
|
||||
use acadrust::xdata::{ExtendedData, XDataValue};
|
||||
use acadrust::{CadDocument, Handle};
|
||||
|
||||
|
|
@ -13,6 +14,7 @@ use acadrust::{CadDocument, Handle};
|
|||
pub const DIMSCALE: i16 = 40; // overall scale (real)
|
||||
pub const DIMASZ: i16 = 41; // arrow size (real)
|
||||
pub const DIMTAD: i16 = 77; // text vertical pos (int16)
|
||||
pub const DIMCLRD: i16 = 176; // dim line colour (int16 = ACI index)
|
||||
pub const DIMGAP: i16 = 147; // text offset / gap (real)
|
||||
pub const DIMLWD: i16 = 371; // dim line lineweight (int16)
|
||||
pub const DIMLDRBLK: i16 = 341; // leader arrow block (handle)
|
||||
|
|
@ -58,6 +60,13 @@ pub fn int(xd: &ExtendedData, code: i16) -> Option<i16> {
|
|||
})
|
||||
}
|
||||
|
||||
/// The colour override for `code`, if present. Dim-colour overrides are stored
|
||||
/// as an ACI index (the same `int16` slot the dimension style uses), so this
|
||||
/// decodes it back into a `Color` (0 = ByBlock, 256 = ByLayer, else indexed).
|
||||
pub fn color(xd: &ExtendedData, code: i16) -> Option<Color> {
|
||||
int(xd, code).map(Color::from_index)
|
||||
}
|
||||
|
||||
/// The handle-valued override for `code`, if present.
|
||||
pub fn handle(xd: &ExtendedData, code: i16) -> Option<Handle> {
|
||||
pairs(xd)
|
||||
|
|
|
|||
Loading…
Reference in a new issue