Add import of polygon from dxf

This commit is contained in:
Evgeny Redikultsev
2025-11-01 21:56:47 +05:00
parent 3dfbb43b73
commit ba0d3e580b
34 changed files with 498 additions and 179 deletions

View File

@@ -0,0 +1,54 @@
using netDxf;
using netDxf.Tables;
using StructureHelperCommon.Infrastructures.Exceptions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace StructureHelperCommon.Services.Exports
{
public class GetDxfLayerLogic : IGetDxfLayerLogic
{
private const string PrimitivesLayer = "STR-PRM";
private const string OpeningsLayer = "STR-OPN";
private const string RebarLayer = "STR-REB";
private const string LayerNameIsUnKnown = ": Layer name is unknown";
public Layer GetOrCreateLayer(DxfDocument dxf, LayerNames layerName)
{
string newLayerName = GetLayerName(layerName);
Layer newLayer = dxf.Layers.Contains(newLayerName)
? dxf.Layers[newLayerName]
: new Layer(newLayerName)
{
Color = GetLayerColor(layerName)
};
if (!dxf.Layers.Contains(newLayerName))
dxf.Layers.Add(newLayer);
return newLayer;
}
public string GetLayerName(LayerNames layerName)
{
if (layerName == LayerNames.StructiralPrimitives) { return PrimitivesLayer; }
else if (layerName == LayerNames.StructuralOpenings) { return OpeningsLayer; }
else if (layerName == LayerNames.StructuralRebars) { return RebarLayer; }
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(layerName) + LayerNameIsUnKnown);
}
}
public AciColor GetLayerColor(LayerNames layerName)
{
if (layerName == LayerNames.StructiralPrimitives) { return AciColor.Blue; }
else if (layerName == LayerNames.StructuralOpenings) { return AciColor.DarkGray; }
else if (layerName == LayerNames.StructuralRebars) { return AciColor.Magenta; }
else
{
throw new StructureHelperException(ErrorStrings.ObjectTypeIsUnknownObj(layerName) + LayerNameIsUnKnown);
}
}
}
}