Add a Shape Library dialog (Nest > Shape Library) for creating drawings
from built-in parametric shapes. Supports configuration presets loaded
from JSON files — ships with 136 standard pipe flanges. Parameters use
TextBox inputs with architectural unit parsing (feet/inches, fractions).
- ShapeLibraryForm with split layout: shape list, preview, parameters
- ShapePreviewControl for auto-zoom rendering with info overlay
- ArchUnits utility for parsing architectural measurements
- SetPreviewDefaults() on all ShapeDefinition subclasses
- Convention-based config discovery (Configurations/{ShapeName}.json)
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
47 lines
1.4 KiB
C#
47 lines
1.4 KiB
C#
using OpenNest.Geometry;
|
|
using System.Collections.Generic;
|
|
|
|
namespace OpenNest.Shapes
|
|
{
|
|
public class FlangeShape : ShapeDefinition
|
|
{
|
|
public double NominalPipeSize { get; set; }
|
|
public double OD { get; set; }
|
|
public double HoleDiameter { get; set; }
|
|
public double HolePatternDiameter { get; set; }
|
|
public int HoleCount { get; set; }
|
|
|
|
public override void SetPreviewDefaults()
|
|
{
|
|
NominalPipeSize = 2;
|
|
OD = 7.5;
|
|
HoleDiameter = 0.875;
|
|
HolePatternDiameter = 5.5;
|
|
HoleCount = 8;
|
|
}
|
|
|
|
public override Drawing GetDrawing()
|
|
{
|
|
var entities = new List<Entity>();
|
|
|
|
// Outer circle
|
|
entities.Add(new Circle(0, 0, OD / 2.0));
|
|
|
|
// Bolt holes evenly spaced on the bolt circle
|
|
var boltCircleRadius = HolePatternDiameter / 2.0;
|
|
var holeRadius = HoleDiameter / 2.0;
|
|
var angleStep = 2.0 * System.Math.PI / HoleCount;
|
|
|
|
for (var i = 0; i < HoleCount; i++)
|
|
{
|
|
var angle = i * angleStep;
|
|
var cx = boltCircleRadius * System.Math.Cos(angle);
|
|
var cy = boltCircleRadius * System.Math.Sin(angle);
|
|
entities.Add(new Circle(cx, cy, holeRadius));
|
|
}
|
|
|
|
return CreateDrawing(entities);
|
|
}
|
|
}
|
|
}
|