Aligned constraint: axis lines, zero collapse, Properties form/reference/description, screen-sized text

Point & line and 2Lines take a text baseline or an ellipse axis as the
line; a zero value folds the points onto the first one; 2Lines turns the
second line about its start. The Properties Constraint section edits
Constraint Form (Dynamic on the *ADSK_CONSTRAINTS layer, Annotational on
the current layer), Reference (driven constraint in parentheses whose
parameter follows the measurement) and Description (stored with the
parameter and the native variable). Dynamic dimensions keep a 12 px text
and 8 px arrows at any zoom, drop trailing zeros and show formulas as
`fx: len=d1*2`; the hidden constraints layer stays out of the layer lists.

Co-Authored-By: Claude Fable 5.1 <[email protected]>
This commit is contained in:
ramox81andClaude Fable 5.1 committed 2026-09-21 16:04:26 +03:00
1 parent 6969c19746
commit 5fab97a7d0
12 files changed
+476 -45

No files matched your search

+36
View File
@@ -204,6 +204,24 @@ impl DimConstraintCommand {
ParametricRef::point(handle, end),
)
}
// A text's baseline or an ellipse's axis is a line whose one
// constraint point is the insertion point / the center.
EntityType::Text(_) | EntityType::MText(_) => {
return Self::axis_target(entity, ParametricRef::text_baseline(handle), ParametricRef::point(handle, 0));
}
EntityType::Ellipse(_) => {
let center = ParametricRef::point(handle, -3);
let major = Self::axis_target(entity, ParametricRef::ellipse_major_axis(handle), center);
let minor = Self::axis_target(entity, ParametricRef::ellipse_minor_axis(handle), center);
let gap = |target: &LineTarget| {
let offset = point - target.ends[0].1;
(offset.x * target.dir.y - offset.y * target.dir.x).abs()
};
return match (major, minor) {
(Some(major), Some(minor)) => Some(if gap(&minor) < gap(&major) { minor } else { major }),
(major, minor) => major.or(minor),
};
}
_ => return None,
};
let start = Self::world(entity, first)?;
@@ -216,6 +234,24 @@ impl DimConstraintCommand {
})
}
/// A directional axis (text baseline, ellipse axis) as a line target
/// whose only constraint point is `anchor`.
fn axis_target(entity: &EntityType, axis: ParametricRef, anchor: ParametricRef) -> Option<LineTarget> {
let [start, end] =
crate::scene::parametric_constraints::directional_axis_endpoints(entity, axis)?;
let (start, end) = (
DVec3::new(start.x, start.y, start.z),
DVec3::new(end.x, end.y, end.z),
);
let dir = (end - start).try_normalize()?;
let anchor_point = Self::world(entity, anchor)?;
Some(LineTarget {
line: axis,
dir,
ends: [(anchor, anchor_point), (anchor, anchor_point)],
})
}
/// A picked line for the current line step, or the message to show.
fn pick_line(&mut self, handle: Handle, point: DVec3) -> Result<LineTarget, &'static str> {
if handle.is_null() {