constraints: hide dynamic dimensions whose constraint did not load

A dynamic dimension is drawn by its constraint at screen size; without
the constraint it is a bare dimension with stretched extension lines.
Those orphans now stay undrawn and unplotted, as in a viewer (#992).

- First-release drawings keep dynamic dimensions on
  *LayerNameForDynamicConstraint; it counts as the dynamic layer.
- The hidden set is refreshed when constraints load, and the loader's
  prepared wires (built before that) are not installed while it holds
  anything.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
Hakan SevenandClaude Opus 5.5 committed 2026-10-15 06:12:42 +03:00
1 parent 6025d8be44
commit 53b93dc98a
4 files changed
+36 -11

No files matched your search

+1 -4
View File
@@ -7860,10 +7860,7 @@ fn radial_leader_tip(dim: &Dimension, text: Vector3) -> Vector3 {
/// A dimensional constraint's dynamic dimension: the reference keeps it on
/// its own hidden layer and draws it by its own rules.
fn dynamic_constraint_dimension(dim: &Dimension) -> bool {
dim.base()
.common
.layer
.eq_ignore_ascii_case(crate::scene::parametric_constraints::DYNAMIC_DIMENSION_LAYER)
crate::scene::parametric_constraints::is_dynamic_dimension_layer(&dim.base().common.layer)
}
/// How far a radial leader runs out from the rim before its hook, and how
+1
View File
@@ -4075,6 +4075,7 @@ impl Scene {
// writes, which happen on the local set during decode.
self.bump_constraints_epoch();
self.import_sweep_expression_links();
self.refresh_hidden_dynamic_dimensions();
}
/// Makes the standard associative graph match the live command model.
+5
View File
@@ -3098,6 +3098,11 @@ impl Scene {
/// so only immutable geometry is transferred and re-stamped here. The
/// optional interaction index is cached against the exact same `Arc`.
pub fn install_prepared_open_geometry(&self, prepared: PreparedOpenGeometry) {
// The loader tessellated before the constraints were read, so its
// wires still hold the dynamic dimensions that must stay hidden.
if !self.hidden_dynamic_dimensions.is_empty() {
return;
}
let block = self.model_space_block_handle();
let scale = crate::scene::annotative::scale_handle_by_name(
&self.document,
+29 -7
View File
@@ -435,6 +435,13 @@ pub const DYNAMIC_DIMENSION_TEXT_PX: f32 = 12.0;
/// dimensional constraint sits on an ordinary layer instead.
pub(crate) const DYNAMIC_DIMENSION_LAYER: &str = "*ADSK_CONSTRAINTS";
/// Whether `layer` holds dynamic dimensions. Drawings from the first
/// parametric release keep them on `*LayerNameForDynamicConstraint`.
pub(crate) fn is_dynamic_dimension_layer(layer: &str) -> bool {
layer.eq_ignore_ascii_case(DYNAMIC_DIMENSION_LAYER)
|| layer.eq_ignore_ascii_case("*LayerNameForDynamicConstraint")
}
/// The text a dynamic dimension shows: CONSTRAINTNAMEFORMAT 0 = name,
/// 1 = value, 2 = name=value, the value with its trailing zeros dropped
/// (`d9=80`, `d1=111.8034`). A parameter defined by a formula shows the
@@ -2499,12 +2506,9 @@ impl super::Scene {
/// form: on an ordinary layer instead of the reference's constraints
/// layer, drawn with its style, plotted, never rescaled to the screen.
pub(crate) fn dimension_is_annotational(&self, handle: Handle) -> bool {
self.document.get_entity(handle).is_some_and(|entity| {
!entity
.common()
.layer
.eq_ignore_ascii_case(DYNAMIC_DIMENSION_LAYER)
})
self.document
.get_entity(handle)
.is_some_and(|entity| !is_dynamic_dimension_layer(&entity.common().layer))
}
/// The document as written to a file: a dynamic dimension's screen-size
@@ -2669,7 +2673,24 @@ impl super::Scene {
/// DYNCONSTRAINTDISPLAY 0 for all of them) and redraws the ones that
/// changed.
pub(crate) fn refresh_hidden_dynamic_dimensions(&mut self) {
let desired: rustc_hash::FxHashSet<Handle> = self
let linked: rustc_hash::FxHashSet<Handle> = self
.parametric_constraints
.iter()
.flat_map(|set| set.dimensions.values().copied())
.collect();
// A dynamic dimension whose constraint did not load cannot be driven
// or placed on screen; like a viewer, leave it undrawn.
let orphans: Vec<Handle> = self
.document
.entities()
.filter(|entity| {
matches!(entity, codec::EntityType::Dimension(_))
&& is_dynamic_dimension_layer(&entity.common().layer)
&& !linked.contains(&entity.common().handle)
})
.map(|entity| entity.common().handle)
.collect();
let mut desired: rustc_hash::FxHashSet<Handle> = self
.parametric_constraints
.iter()
.flat_map(|set| {
@@ -2681,6 +2702,7 @@ impl super::Scene {
})
})
.collect();
desired.extend(orphans);
if desired == self.hidden_dynamic_dimensions {
return;
}