feat: DRL钻带更改参数功能 — 支持.drl文件从A01-A14参数文件按直径替换H/Z/S/F/U参数段

This commit is contained in:
2026-08-07 07:18:23 +08:00
parent 8a0222e903
commit d234bb06dc
6 changed files with 458 additions and 3 deletions

View File

@@ -53,6 +53,7 @@ namespace DrillTools
string extension = Path.GetExtension(filePath).ToLowerInvariant();
bool canScaleDrillTape = extension == ".dr2" || extension == ".dpin";
bool isRouFile = extension == ".rou" || extension == ".rou1" || extension == ".rou2" || extension == ".roux";
bool isDrlFile = extension == ".drl";
double minDrill = viewModel.MinDrillDiameter;
double minSlot = viewModel.MinSlotDiameter;
double minEA = viewModel.MinEADiameter;
@@ -85,7 +86,8 @@ namespace DrillTools
canClearParameters,
canGeneratePpDrillTape,
canScaleDrillTape,
canReplaceRouParameters: isRouFile);
canReplaceRouParameters: isRouFile,
canReplaceDrlParameters: isDrlFile);
selectionWindow.ShowDialog();
switch (selectionWindow.SelectedAction)
@@ -114,6 +116,10 @@ namespace DrillTools
PerformRouParameterReplace(filePath);
Shutdown();
break;
case StartupAction.ReplaceDrlParameters:
PerformDrlParameterReplace(filePath);
Shutdown();
break;
default:
Shutdown();
break;
@@ -363,6 +369,60 @@ namespace DrillTools
}
}
private static void PerformDrlParameterReplace(string filePath)
{
try
{
#if DEBUG
string paramDir = @"C:\Users\14244\source\repos\Aoh\DrillTools\DRL-canshu";
#else
string paramDir = @"\\ah-file-2\workdata\Drill\DRILLING\etc";
#endif
if (!Directory.Exists(paramDir))
{
System.Windows.MessageBox.Show(
$"参数文件目录不存在:\n{paramDir}",
"错误",
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
var selectionWindow = new DrlParameterSelectionWindow(paramDir);
selectionWindow.ShowDialog();
if (selectionWindow.SelectedFilePath == null)
return;
DrlParameterReplacer.ReplaceParameters(filePath, selectionWindow.SelectedFilePath, out var unmatchedDiameters);
string message = $"参数替换完成:\n{filePath}\n原文件已备份为:\n{Path.GetFileName(filePath)}.bak";
if (unmatchedDiameters.Count > 0)
{
var diaStrings = unmatchedDiameters.Select(d => d.ToString("F3", CultureInfo.InvariantCulture)).ToList();
message += $"\n\n⚠ 以下直径未在参数文件中找到匹配,已保留原行:\n{string.Join(", ", diaStrings)}";
}
System.Windows.MessageBox.Show(
message,
"参数替换完成",
MessageBoxButton.OK,
MessageBoxImage.Information);
}
catch (OperationCanceledException)
{
}
catch (Exception ex)
{
System.Windows.MessageBox.Show(
$"参数替换失败:\n{ex.Message}",
"错误",
MessageBoxButton.OK,
MessageBoxImage.Error);
}
}
/// <summary>
/// 从 MainWindowViewModel.Tools 独立遍历计算叠板用最小刀径。
/// 分类逻辑与 UpdateMinDiameterInfo 一致(按尾号使用标准),不排除 0.749mm;