Files
OpenNest/OpenNest.Core/Dimensions/DrawingDimension.cs
T
ajandClaude Opus 5.5 ca693285bb feat(cad): add radius and diameter dimensions
Holes and radii need sizes on the drawing as well as the overall extents. Select
circles or arcs, right-click and choose Add Radius Dimension or Add Diameter
Dimension. The value is measured live from the curve, found by its entity ID, so
it follows edits; only the leader angle and label offset are saved. A radius on
an arc stays on its sweep, and labels are kept clear of the curve and center.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-30 22:47:56 -04:00

49 lines
1.8 KiB
C#

using System;
namespace OpenNest.Dimensions
{
public enum DimensionKind
{
/// <summary>The part's overall size along X, drawn above or below it.</summary>
OverallHorizontal,
/// <summary>The part's overall size along Y, drawn right or left of it.</summary>
OverallVertical,
/// <summary>A circle's or arc's radius, on a leader from its center.</summary>
Radius,
/// <summary>A circle's or arc's diameter, on a leader across it.</summary>
Diameter,
}
/// <summary>
/// An annotation on a drawing. Only its placement is stored: the value is measured from the
/// geometry each time it is resolved, so it cannot go stale. It never affects the program.
/// </summary>
public sealed class DrawingDimension
{
public DimensionKind Kind { get; set; }
/// <summary>
/// Never zero. Overall dimensions: distance from the part's extents to the dimension line,
/// positive above a horizontal dimension's part or right of a vertical one's. Radius and
/// diameter: distance from the curve to the label along the leader, positive outside.
/// </summary>
public double Offset { get; set; }
/// <summary>The circle or arc a radius or diameter measures; empty for overall dimensions.</summary>
public Guid EntityId { get; set; }
/// <summary>Radius and diameter: the leader's direction from the center, in radians.</summary>
public double Angle { get; set; }
public bool IsRadial => IsRadialKind(Kind);
public static bool IsRadialKind(DimensionKind kind) =>
kind is DimensionKind.Radius or DimensionKind.Diameter;
public DrawingDimension Clone() => new() { Kind = Kind, Offset = Offset, EntityId = EntityId, Angle = Angle };
}
}