Skip to content

Commit

Permalink
Merge pull request #358 from DomCR/code-examples
Browse files Browse the repository at this point in the history
readEntities example
  • Loading branch information
DomCR committed Jun 11, 2024
2 parents 43fab9e + bc7b102 commit bdafc5f
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 45 deletions.
44 changes: 0 additions & 44 deletions ACadSharp.Examples/IOExamples.cs

This file was deleted.

35 changes: 34 additions & 1 deletion ACadSharp.Examples/ReaderExamples.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using ACadSharp.Examples.Common;
using ACadSharp.Entities;
using ACadSharp.Examples.Common;
using ACadSharp.IO;
using System.Collections.Generic;

namespace ACadSharp.Examples
{
Expand Down Expand Up @@ -30,5 +32,36 @@ public static void ReadDwg(string file)
CadDocument doc = reader.Read();
}
}

/// <summary>
/// Read the entities section from a dxf file and add them to a <see cref="CadDocument"/>
/// </summary>
/// <param name="file"></param>
public static void ReadEntitiesFromDxf(string file)
{
CadDocument doc = new CadDocument();
List<Entity> entities = new List<Entity>();

using (DxfReader reader = new DxfReader(file))
{
reader.OnNotification += NotificationHelper.LogConsoleNotification;
entities = reader.ReadEntities();
}

doc.Entities.AddRange(entities);
}

/// <summary>
/// Read the tables section from a dxf file.
/// </summary>
/// <param name="file"></param>
public static void ReadTablesFromDxf(string file)
{
using (DxfReader reader = new DxfReader(file))
{
reader.OnNotification += NotificationHelper.LogConsoleNotification;
CadDocument doc = reader.ReadTables();
}
}
}
}

0 comments on commit bdafc5f

Please sign in to comment.