diff --git a/PepApi.Core/PepHelper.cs b/PepApi.Core/PepHelper.cs index ae9a2ad..5e54603 100644 --- a/PepApi.Core/PepHelper.cs +++ b/PepApi.Core/PepHelper.cs @@ -117,14 +117,30 @@ namespace PepApi.Core part.QtyNested = 0; var nestedOn = new List(); - var partName = part.Name.ToUpper(); + // Normalize drawing names by stripping directories and extensions + // to make matching resilient to format differences between sources. + string Normalize(string? name) + { + if (string.IsNullOrWhiteSpace(name)) return string.Empty; + try + { + var fileOnly = System.IO.Path.GetFileNameWithoutExtension(name); + return fileOnly.ToUpperInvariant(); + } + catch + { + return name.Trim().ToUpperInvariant(); + } + } + + var partName = Normalize(part.Name); for (int i = 0; i < nest.Plates.Count; i++) { var plate = nest.Plates[i]; var qtyNested = 0; - qtyNested = plate.Parts.Count(p => p.DrawingName?.ToUpper() == partName); + qtyNested = plate.Parts.Count(p => Normalize(p.DrawingName) == partName); // plate.Duplicates is actually the quantity, so 1 Duplicate = 1 plate qtyNested *= plate.Duplicates;