fix: return etch lines and support additional bend layer names
- Fix GetEtchLines() using yield break instead of return lines, which caused all etch lines to be silently discarded - Support BEND LINES and BENDLINES layer names in addition to BEND - Move all bend lines to BEND layer before processing - Migrate csproj from .NET Framework 4.8 to SDK-style net8.0-windows Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -68,7 +68,18 @@ namespace EtchBendLines
|
|||||||
|
|
||||||
private bool IsBendLine(Line line)
|
private bool IsBendLine(Line line)
|
||||||
{
|
{
|
||||||
return line.Linetype.Name == "CENTERX2" && line.Layer.Name == "BEND";
|
if (line.Linetype.Name != "CENTERX2")
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch (line.Layer.Name.ToUpperInvariant())
|
||||||
|
{
|
||||||
|
case "BEND":
|
||||||
|
case "BEND LINES":
|
||||||
|
case "BENDLINES":
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<MText> GetBendNotes()
|
private List<MText> GetBendNotes()
|
||||||
|
|||||||
@@ -1,69 +1,21 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
||||||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
<TargetFramework>net8.0-windows</TargetFramework>
|
||||||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
|
<OutputType>Library</OutputType>
|
||||||
<ProjectGuid>{229C2FB9-6AD6-4A5D-B83A-D1146573D6F9}</ProjectGuid>
|
<ImplicitUsings>disable</ImplicitUsings>
|
||||||
<OutputType>Exe</OutputType>
|
<Nullable>disable</Nullable>
|
||||||
<RootNamespace>EtchBendLines</RootNamespace>
|
<RootNamespace>EtchBendLines</RootNamespace>
|
||||||
<AssemblyName>EtchBendLines</AssemblyName>
|
<AssemblyName>EtchBendLines</AssemblyName>
|
||||||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion>
|
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
|
||||||
<FileAlignment>512</FileAlignment>
|
|
||||||
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
|
|
||||||
<TargetFrameworkProfile />
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugSymbols>true</DebugSymbols>
|
|
||||||
<DebugType>full</DebugType>
|
|
||||||
<Optimize>false</Optimize>
|
|
||||||
<OutputPath>bin\Debug\</OutputPath>
|
|
||||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
|
|
||||||
<PlatformTarget>AnyCPU</PlatformTarget>
|
|
||||||
<DebugType>pdbonly</DebugType>
|
|
||||||
<Optimize>true</Optimize>
|
|
||||||
<OutputPath>bin\Release\</OutputPath>
|
|
||||||
<DefineConstants>TRACE</DefineConstants>
|
|
||||||
<ErrorReport>prompt</ErrorReport>
|
|
||||||
<WarningLevel>4</WarningLevel>
|
|
||||||
</PropertyGroup>
|
|
||||||
<PropertyGroup>
|
|
||||||
<NoWin32Manifest>true</NoWin32Manifest>
|
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Reference Include="System" />
|
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
|
||||||
<Reference Include="System.Configuration" />
|
|
||||||
<Reference Include="System.Core" />
|
|
||||||
<Reference Include="System.Xml.Linq" />
|
|
||||||
<Reference Include="System.Data.DataSetExtensions" />
|
|
||||||
<Reference Include="Microsoft.CSharp" />
|
|
||||||
<Reference Include="System.Data" />
|
|
||||||
<Reference Include="System.Net.Http" />
|
|
||||||
<Reference Include="System.Xml" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="AppConfig.cs" />
|
<ProjectReference Include="..\netDxf\netDxf\netDxf.csproj" />
|
||||||
<Compile Include="Bend.cs" />
|
|
||||||
<Compile Include="BendDirection.cs" />
|
|
||||||
<Compile Include="BendLineExtractor.cs" />
|
|
||||||
<Compile Include="Etcher.cs" />
|
|
||||||
<Compile Include="Extensions.cs" />
|
|
||||||
<Compile Include="Program.cs" />
|
|
||||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
|
||||||
<None Include="App.config" />
|
|
||||||
</ItemGroup>
|
|
||||||
<ItemGroup>
|
|
||||||
<ProjectReference Include="..\netDxf\netDxf\netDxf.csproj">
|
|
||||||
<Project>{785380e0-ceb9-4c34-82e5-60d0e33e848e}</Project>
|
|
||||||
<Name>netDxf</Name>
|
|
||||||
</ProjectReference>
|
|
||||||
</ItemGroup>
|
|
||||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
|
||||||
</Project>
|
</Project>
|
||||||
+13
-7
@@ -40,12 +40,10 @@ namespace EtchBendLines
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Bend> ExtractUpBends(DxfDocument doc)
|
private List<Bend> ExtractBends(DxfDocument doc)
|
||||||
{
|
{
|
||||||
// your existing BendLineExtractor logic
|
|
||||||
var extractor = new BendLineExtractor(doc);
|
var extractor = new BendLineExtractor(doc);
|
||||||
return extractor.GetBendLines()
|
return extractor.GetBendLines();
|
||||||
.Where(b => b.Direction == BendDirection.Up);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HashSet<string> BuildExistingKeySet(DxfDocument doc)
|
private HashSet<string> BuildExistingKeySet(DxfDocument doc)
|
||||||
@@ -93,7 +91,15 @@ namespace EtchBendLines
|
|||||||
Console.WriteLine(filePath);
|
Console.WriteLine(filePath);
|
||||||
|
|
||||||
var doc = LoadDocument(filePath);
|
var doc = LoadDocument(filePath);
|
||||||
var upBends = ExtractUpBends(doc);
|
var bends = ExtractBends(doc);
|
||||||
|
|
||||||
|
// Ensure all bend lines are on the BEND layer
|
||||||
|
foreach (var bend in bends)
|
||||||
|
{
|
||||||
|
bend.Line.Layer = BendLayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
var upBends = bends.Where(b => b.Direction == BendDirection.Up);
|
||||||
var existing = BuildExistingKeySet(doc);
|
var existing = BuildExistingKeySet(doc);
|
||||||
|
|
||||||
InsertEtchLines(doc, upBends, existing, etchLength);
|
InsertEtchLines(doc, upBends, existing, etchLength);
|
||||||
@@ -119,7 +125,7 @@ namespace EtchBendLines
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private IEnumerable<Line> GetEtchLines(Line bendLine, double etchLength)
|
private List<Line> GetEtchLines(Line bendLine, double etchLength)
|
||||||
{
|
{
|
||||||
var lines = new List<Line>();
|
var lines = new List<Line>();
|
||||||
|
|
||||||
@@ -176,7 +182,7 @@ namespace EtchBendLines
|
|||||||
line.Layer = EtchLayer;
|
line.Layer = EtchLayer;
|
||||||
}
|
}
|
||||||
|
|
||||||
yield break;
|
return lines;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user