mirror of
https://github.com/storytold/cadcraft.git
synced 2026-11-11 16:32:22 -06:00
* Dimensions: fill in the measurement when one is created (#2421) A dimension made in the session kept measurement 0.0 until it was saved and reopened. add_dim now sets it with the geometry call the DXF/DWG writer uses for group 42. Block names are still assigned at save time. Test: a_new_dimension_reports_its_measurement. * Parity checklist: regenerated after merging main * Dimensions: a jogged radius dimension stores its radius as the measurement (#2421) draw_jogged_radius set the text but not DimGeometry.measurement, so DIMJOGGED dimensions kept measurement 0 (and the DXF/DWG group 42 was 0). It now sets the radius. Test: jogged_radius asserts the stored measurement. * Parity checklist: regenerated after merging main * Dimensions: fill in a new dimension's text position when it is created (#2421) A dimension made in the session kept text_mid (0,0) until it was saved and reopened. add_dim now sets it from the same dimension_geometry result as the measurement, the position the writer puts in group 11, unless the user placed the text. Test: a_new_dimension_reports_its_text_position. --------- Co-authored-by: Brandon Thomas <echelon@gmail.com>
This commit is contained in:
@@ -48,6 +48,19 @@ pub(super) fn add_dim(s: &mut Session, k: EntityKind) -> Result<Handle> {
|
||||
{
|
||||
dm.assoc = crate::assoc::reassociate(s.doc()?, &s.space(), dm);
|
||||
}
|
||||
// The measurement is what the DXF/DWG writer computes from the geometry (group 42); filling it
|
||||
// in now means queries show it before the drawing is saved and reopened (#2421).
|
||||
if let EntityKind::Dimension(dm) = &mut k
|
||||
&& let Ok(d) = s.doc()
|
||||
{
|
||||
let style = d.dim_style(&dm.style).cloned().unwrap_or_default();
|
||||
let g = cadcraft_render::dimension_geometry(dm, &style, d.header.f64("DIMSCALE", 1.0));
|
||||
dm.measurement = g.measurement;
|
||||
// The text position the writer puts in group 11 when the user has not placed the text.
|
||||
if !dm.user_text_pos {
|
||||
dm.text_mid = g.text_pos.to3(0.0);
|
||||
}
|
||||
}
|
||||
let h = s.add_entity(k)?;
|
||||
s.last_dim = Some(h);
|
||||
Ok(h)
|
||||
|
||||
Reference in New Issue
Block a user