Add import primitives to cross-section
This commit is contained in:
@@ -1,19 +1,27 @@
|
||||
using netDxf;
|
||||
using netDxf.Entities;
|
||||
using netDxf.Header;
|
||||
using System;
|
||||
using StructureHelperCommon.Services.Exports.Factories;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using System.IO;
|
||||
|
||||
namespace StructureHelperCommon.Services.Exports
|
||||
{
|
||||
public class ShapesAllImportFromDxfLogic : IImportFromFileLogic
|
||||
public class EntitiesImportFromDxfLogic : IImportFromFileLogic
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public List<EntityObject> Entities { get; set; } = [];
|
||||
public void Import()
|
||||
{
|
||||
string extension = Path.GetExtension(FileName).ToLowerInvariant();
|
||||
if (extension == ".dxf")
|
||||
{
|
||||
GetEntities();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void GetEntities()
|
||||
{
|
||||
// this check is optional but recommended before loading a DXF file
|
||||
DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(FileName);
|
||||
@@ -1,11 +1,6 @@
|
||||
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
|
||||
{
|
||||
|
||||
@@ -8,6 +8,6 @@ namespace StructureHelperCommon.Services.Exports
|
||||
{
|
||||
public interface IImportFromFileLogic : IImportLogic
|
||||
{
|
||||
string FileName { get; set; }
|
||||
string? FileName { get; set; }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,18 +1,25 @@
|
||||
using netDxf.Entities;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace StructureHelperCommon.Services.Exports
|
||||
{
|
||||
public class SinglePolyline2DImportFromDxfLogic : IImportFromFileLogic
|
||||
{
|
||||
public string FileName { get; set; }
|
||||
public Polyline2D Polyline2D { get; private set; }
|
||||
public string? FileName { get; set; }
|
||||
public LayerNames LayerName { get; set; } = LayerNames.StructiralPrimitives;
|
||||
public List<Polyline2D> Polyline2Ds { get; private set; } = [];
|
||||
public void Import()
|
||||
{
|
||||
var importLogic = new ShapesAllImportFromDxfLogic() { FileName = FileName};
|
||||
var importLogic = new EntitiesImportFromDxfLogic()
|
||||
{
|
||||
FileName = FileName
|
||||
};
|
||||
importLogic.Import();
|
||||
var entities = importLogic.Entities;
|
||||
Polyline2D = entities.Single(x => x is Polyline2D) as Polyline2D;
|
||||
string layerName = new GetDxfLayerLogic().GetLayerName(LayerName);
|
||||
var collection = entities.Where(x => x is Polyline2D && x.Layer.Name == layerName).ToList();
|
||||
collection.ForEach(x => Polyline2Ds.Add(x as Polyline2D));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user