fix: detect bend lines from SolidWorks DXF exports
Three issues prevented bend line detection after the ACadSharp migration: 1. IsBendLine required layer "BEND" but SolidWorks exports bend lines on layer "0" with CENTERX2 linetype. Added "0" as accepted layer. 2. Bend note regex used literal ° which failed when ACadSharp reads the degree symbol as multi-byte "°" due to ANSI/UTF-8 encoding mismatch. Changed to [^R\d]* to tolerate any characters between angle and R. 3. Radius filter excluded bends with null Radius (unparsed notes). Nullable comparison null <= 4.0 evaluates to false in C#, filtering out all bends. Added null check to include unparsed bends. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -36,7 +36,7 @@ namespace EtchBendLines
|
|||||||
/// The regular expression pattern the bend note must match
|
/// The regular expression pattern the bend note must match
|
||||||
/// </summary>
|
/// </summary>
|
||||||
static readonly Regex bendNoteRegex = new Regex(
|
static readonly Regex bendNoteRegex = new Regex(
|
||||||
@"\b(?<direction>UP|DOWN|DN)\s+(?<angle>\d+(\.\d+)?)°?\s*R\s*(?<radius>\d+(\.\d+)?)\b",
|
@"\b(?<direction>UP|DOWN|DN)\s+(?<angle>\d+(\.\d+)?)[^R\d]*R\s*(?<radius>\d+(\.\d+)?)\b",
|
||||||
RegexOptions.Compiled | RegexOptions.IgnoreCase
|
RegexOptions.Compiled | RegexOptions.IgnoreCase
|
||||||
);
|
);
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ namespace EtchBendLines
|
|||||||
|
|
||||||
AssignBendDirections(bends, bendNotes);
|
AssignBendDirections(bends, bendNotes);
|
||||||
|
|
||||||
return bends.Where(b => b.Radius <= MaxBendRadius).ToList();
|
return bends.Where(b => b.Radius == null || b.Radius <= MaxBendRadius).ToList();
|
||||||
}
|
}
|
||||||
|
|
||||||
private bool IsBendLine(Line line)
|
private bool IsBendLine(Line line)
|
||||||
@@ -76,6 +76,7 @@ namespace EtchBendLines
|
|||||||
|
|
||||||
switch (line.Layer.Name.ToUpperInvariant())
|
switch (line.Layer.Name.ToUpperInvariant())
|
||||||
{
|
{
|
||||||
|
case "0":
|
||||||
case "BEND":
|
case "BEND":
|
||||||
case "BEND LINES":
|
case "BEND LINES":
|
||||||
case "BENDLINES":
|
case "BENDLINES":
|
||||||
|
|||||||
Reference in New Issue
Block a user