Handle G84 circular expansion hole counts

This commit is contained in:
2026-05-21 12:39:46 +08:00
parent a27cef82b2
commit 21fc6d4c4c
2 changed files with 90 additions and 3 deletions

View File

@@ -54,7 +54,7 @@ namespace DrillTools.Integration
foreach (var hole in toolHoles)
{
if (hole.Type == HoleType.Slot)
if (hole.Type == HoleType.Slot || hole.Type == HoleType.CircularExpansion)
{
hasSlotHoles = true;
break;
@@ -135,6 +135,12 @@ namespace DrillTools.Integration
string location = $"{startLocation}G85{endLocation}";
locations.Add(location);
}
else if (hole.Type == HoleType.CircularExpansion)
{
slotHoles += hole.DrillHitCount;
slotCount++;
locations.Add(hole.OriginalCommand);
}
}
}
@@ -326,6 +332,24 @@ namespace DrillTools.Integration
var trimmedLine = line.Trim();
if (string.IsNullOrEmpty(trimmedLine)) continue;
// 检查是否是圆形扩孔G84指令
var circularExpansionPattern = @"X([+-]?\d+\.?\d*)Y([+-]?\d+\.?\d*)G84X([+-]?\d+\.?\d*)";
var circularExpansionMatch = Regex.Match(trimmedLine, circularExpansionPattern);
if (circularExpansionMatch.Success)
{
var expansion = SlotHoleCalculator.ParseCircularExpansionFromG84(circularExpansionMatch.Value, tool.Diameter);
holes.Add(new HoleInfo
{
ToolNumber = tool.Number,
Type = HoleType.CircularExpansion,
CircularExpansion = expansion,
DrillHitCount = SlotHoleCalculator.CalculateCircularExpansionHoleCount(expansion),
OriginalCommand = trimmedLine
});
continue;
}
// 检查是否是槽孔G85指令
var slotPattern = @"X([+-]?\d+\.?\d*)Y([+-]?\d+\.?\d*)G85X([+-]?\d+\.?\d*)Y([+-]?\d+\.?\d*)";
var slotMatch = Regex.Match(trimmedLine, slotPattern);
@@ -450,6 +474,9 @@ namespace DrillTools.Integration
public HoleType Type { get; set; }
public Point2D Position { get; set; }
public LineSlot Slot { get; set; }
public CircularExpansion CircularExpansion { get; set; }
public int DrillHitCount { get; set; }
public string OriginalCommand { get; set; } = string.Empty;
}
/// <summary>
@@ -458,7 +485,8 @@ namespace DrillTools.Integration
public enum HoleType
{
Regular, // 普通圆孔
Slot // 槽孔
Slot, // 槽孔
CircularExpansion // 圆形扩孔
}
/// <summary>