Add import of polygon from dxf
This commit is contained in:
54
StructureHelperCommon/Services/Exports/GetDxfLayerLogic.cs
Normal file
54
StructureHelperCommon/Services/Exports/GetDxfLayerLogic.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user