dxf 文件读取
🥩效果
读取后经过处理的效果
🍜 资源
dxf文件读取库
(包含Demo.cs 案例)
🍱入门
unity 需要切换到.NET Framework或.NET 4.0
加载dxf文件
FileStream stream = File.OpenRead(filePath);
版本检查
版本过低不支持哦!
DxfVersion dxfVersion = DxfDocument.CheckDxfFileVersion(stream, out bool isBinary);
如果dxfVersion < DxfVersion.AutoCad2000 则无法加载需要提示用户!
加载数据
DxfDocument dxf = DxfDocument.Load(stream, new List<string> { @".\Support" });
获取某个图层上的线段
var layerName = "墙";
netDxf.Tables.Layer layer = dxf.Layers.Where(layer => layerName.Equals(layer.Name)).FirstOrDefault();
var refs = dxf.Layers.GetReferences(layer);
foreach (var item in refs)
{
if (item is Line line)
{
//处理线段
}
}
🍰支持的 DXF entities
- 3dFace
- Arc
- Circle
- Dimensions (aligned, linear, radial, diametric, 3 point angular, 2 line angular, arc length, and ordinate)
- Ellipse
- Hatch (including Gradient patterns)
- Image
- Insert (block references and attributes, dynamic blocks are not supported)
- Leader
- Line
- LwPolyline (light weight polyline)
- Mesh
- MLine
- MText
- Point
- Polyline (Polyline2D, Polyline3D, PolyfaceMesh, and PolygonMesh)
- Ray
- Shape
- Solid
- Spline
- Text
- Tolerance
- Trace
- Underlay (DGN, DWF, and PDF underlays)
- Wipeout
- XLine (aka construction line)
版权声明:本文为qq_26318597原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。