using netDxf; using netDxf.Header; using System.IO; using Line = netDxf.Entities.Line; namespace RhSolutions.Services; public class RhDxfWriter : IExcelWriter { public void WriteProducts(Dictionary products) { WriteProducts(new[] { (string.Empty, products) }); } public void WriteProducts(IEnumerable<(string, Dictionary)> products) { // your DXF file name string file = "sample.dxf"; // create a new document, by default it will create an AutoCad2000 DXF version DxfDocument doc = new DxfDocument(); // an entity Line entity = new Line(new Vector2(5, 5), new Vector2(10, 5)); // add your entities here doc.Entities.Add(entity); // save to file doc.Save(file); // this check is optional but recommended before loading a DXF file DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(file); // netDxf is only compatible with AutoCad2000 and higher DXF versions if (dxfVersion < DxfVersion.AutoCad2000) return; // load file DxfDocument loaded = DxfDocument.Load(file); string docPath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); using (StreamWriter outputFile = new StreamWriter(Path.Combine(docPath, file))) { outputFile.Write(loaded); } } public void Dispose() { } }