Skip to content

Commit bdafc5f

Browse files
authored
Merge pull request #358 from DomCR/code-examples
readEntities example
2 parents 43fab9e + bc7b102 commit bdafc5f

File tree

2 files changed

+34
-45
lines changed

2 files changed

+34
-45
lines changed

ACadSharp.Examples/IOExamples.cs

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

ACadSharp.Examples/ReaderExamples.cs

Lines changed: 34 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,36 @@ 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+
}
53+
54+
/// <summary>
55+
/// Read the tables section from a dxf file.
56+
/// </summary>
57+
/// <param name="file"></param>
58+
public static void ReadTablesFromDxf(string file)
59+
{
60+
using (DxfReader reader = new DxfReader(file))
61+
{
62+
reader.OnNotification += NotificationHelper.LogConsoleNotification;
63+
CadDocument doc = reader.ReadTables();
64+
}
65+
}
3366
}
3467
}

0 commit comments

Comments
 (0)