Skip to content

Commit 3eb33ee

Browse files
committed
readEntities example
1 parent 43fab9e commit 3eb33ee

File tree

2 files changed

+21
-45
lines changed

2 files changed

+21
-45
lines changed

ACadSharp.Examples/IOExamples.cs

Lines changed: 0 additions & 44 deletions
This file was deleted.

ACadSharp.Examples/ReaderExamples.cs

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1-
using ACadSharp.Examples.Common;
1+
using ACadSharp.Entities;
2+
using ACadSharp.Examples.Common;
23
using ACadSharp.IO;
4+
using System.Collections.Generic;
35

46
namespace ACadSharp.Examples
57
{
@@ -30,5 +32,23 @@ public static void ReadDwg(string file)
3032
CadDocument doc = reader.Read();
3133
}
3234
}
35+
36+
/// <summary>
37+
/// Read the entities section from a dxf file and add them to a <see cref="CadDocument"/>
38+
/// </summary>
39+
/// <param name="file"></param>
40+
public static void ReadEntitiesFromDxf(string file)
41+
{
42+
CadDocument doc = new CadDocument();
43+
List<Entity> entities = new List<Entity>();
44+
45+
using (DxfReader reader = new DxfReader(file))
46+
{
47+
reader.OnNotification += NotificationHelper.LogConsoleNotification;
48+
entities = reader.ReadEntities();
49+
}
50+
51+
doc.Entities.AddRange(entities);
52+
}
3353
}
3454
}

0 commit comments

Comments
 (0)