Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/nanoLogika/ACadSharp
Browse files Browse the repository at this point in the history
  • Loading branch information
mme1950 committed Jun 18, 2024
2 parents 1ae8912 + 711e9a4 commit 1afa881
Show file tree
Hide file tree
Showing 113 changed files with 7,431 additions and 4,859 deletions.
1 change: 1 addition & 0 deletions ACadSharp.Examples/Common/NotificationHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public static void LogConsoleNotification(object sender, NotificationEventArgs e

//Write in the console all the messages
Console.WriteLine(e.Message);
Console.ResetColor();
}
}
}
44 changes: 0 additions & 44 deletions ACadSharp.Examples/IOExamples.cs

This file was deleted.

1 change: 1 addition & 0 deletions ACadSharp.Examples/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using ACadSharp.Tables;
using ACadSharp.Tables.Collections;
using System;
using System.Diagnostics;
using System.Linq;

namespace ACadSharp.Examples
Expand Down
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();
}
}
}
}
8 changes: 8 additions & 0 deletions ACadSharp.Tests/Common/EntityFactory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,14 @@ public static Entity Create(Type type, bool randomize = true)
style.Flags = style.Flags.AddFlag(StyleFlags.IsShape);
e = new Shape(style);
}
else if (type == typeof(RasterImage))
{
var def = new ACadSharp.Objects.ImageDefinition
{
Name = "Mock_def"
};
e = new RasterImage(def);
}
else
{
e = Activator.CreateInstance(type);
Expand Down
Loading

0 comments on commit 1afa881

Please sign in to comment.