NetDxf 开发笔记-01
netdxf介绍github库
https://github.com/haplokuon/netDxf
netDxf是一个.net库,用C语言编程,用于读取和写入AutoCAD DXF文件。它支持文本和二进制格式的AutoCad2000、AutoCad2004、AutoCad2007、AutoCad2010、AutoCad2013和AutoCAD2018DXF数据库版本。
这个库很容易使用,我尽量使过程简单明了,例如,您不需要用图层、样式或线型定义填充表格部分。每次添加新项时,DxfDocument都会处理这个问题。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | public static void Main() { // 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.AddEntity(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); } |
支持的实体
- 3dFace
- Arc
- Circle
- Dimensions (aligned, linear, radial, diametric, 3 point angular, 2 line angular, and ordinate)
- Ellipse
- Hatch (including Gradient patterns)
- Image
- Insert (block references and attributes)
- Leader
- Line
- LwPolyline (light weight polyline)
- Mesh
- MLine
- MText
- Point
- PolyfaceMesh
- Polyline
- Ray
- Shape
- Solid
- Spline
- Text
- Tolerance
- Trace
- Underlay (DGN, DWF, and PDF underlays)
- Wipeout
- XLine (aka construction line)
所有实体都可以分组。所有DXF对象都可能包含扩展数据信息。AutoCad表格图元将作为插入(块参照)导入。支持简单线型和复杂线型。库永远无法读取某些实体,如面域、曲面和三维实体,因为它们依赖于未记录的专有数据。
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!