DCDIAMETER/DCRADIUS: the reference flow with a real radial dimension

The commands ask for the circle or arc themselves, report the measured
size, take a dimension line location and then the value or name and
value, creating a radius or diameter dimension as the constraint's
dynamic dimension with a radN/diaN parameter, refusing a second radial
constraint on the same object and any non-positive value.

Co-Authored-By: Claude Opus 5 <[email protected]>
This commit is contained in:
ramox81andClaude Opus 5 committed 2026-09-22 15:21:11 +03:00
1 parent 64c020293a
commit 19204d1b2c
8 files changed
+531 -24

No files matched your search

+19
View File
@@ -87,6 +87,25 @@ impl DiameterDimensionCommand {
}
}
/// A diameter dimension for a dimensional constraint: the dimension line
/// runs through the centre towards `location`, and the style places the
/// text.
pub(crate) fn diameter_constraint_entity(
center: DVec3,
radius: f64,
location: DVec3,
text: Option<String>,
) -> Option<EntityType> {
let direction = super::radius_dim::radial_direction(center, location)?;
let chord = center + direction * radius;
let far_chord = center - direction * radius;
let mut dim = DimensionDiameter::new(v3(chord), v3(far_chord));
dim.leader_length = chord.distance(location).max(radius * 0.5);
dim.base.actual_measurement = dim.measurement();
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
Some(EntityType::Dimension(Dimension::Diameter(dim)))
}
impl CadCommand for DiameterDimensionCommand {
fn set_working_plane(&mut self, _plane: WorkingPlane) {
}
+25
View File
@@ -88,6 +88,31 @@ impl RadiusDimensionCommand {
}
}
/// A radius dimension for a dimensional constraint: the leader leaves the
/// centre towards `location`, and the style places the text.
pub(crate) fn radius_constraint_entity(
center: DVec3,
radius: f64,
location: DVec3,
text: Option<String>,
) -> Option<EntityType> {
let direction = radial_direction(center, location)?;
let chord = center + direction * radius;
let mut dim = DimensionRadius::new(v3(center), v3(chord));
dim.base.definition_point = v3(chord);
dim.leader_length = chord.distance(location).max(radius * 0.5);
dim.base.actual_measurement = dim.measurement();
crate::entities::dimension::set_dimension_text_override(&mut dim.base, text);
Some(EntityType::Dimension(Dimension::Radius(dim)))
}
/// The unit direction a radial constraint's dimension points in, from the
/// centre to where its dimension line was picked.
pub(crate) fn radial_direction(center: DVec3, location: DVec3) -> Option<DVec3> {
let delta = location - center;
(delta.length() > 1.0e-9).then(|| delta.normalize())
}
impl CadCommand for RadiusDimensionCommand {
fn set_working_plane(&mut self, _plane: WorkingPlane) {
}