netdxf 用法_netDxf

netDxf

netDxf 2.3.0 Copyright(C) 2009-2019 Daniel Carvajal, Licensed under LGPL

Description

netDxf is a .net library programmed in C# to read and write AutoCAD dxf files. It supports AutoCad2000, AutoCad2004, AutoCad2007, AutoCad2010, AutoCad2013, and AutoCad2018 dxf database versions, in both text and binary format.

The library is easy to use and I tried to keep the procedures as straightforward as possible, for example you will not need to fill up the table section with layers, styles or line type definitions. The DxfDocument will take care of that every time a new item is added.

If you need more information, you can find the official dxf documentation here.

Code example:

public static void Main()

{

// your dxf file name

string file = "sample.dxf";

// by default it will create an AutoCad2000 DXF version

DxfDocument dxf = new DxfDocument();

// an entity

Line entity = new Line(new Vector2(5, 5), new Vector2(10, 5));

// add your entities here

dxf.AddEntity(entity);

// save to file

dxf.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 version

if (dxfVersion < DxfVersion.AutoCad2000) return;

// load file

DxfDocument loaded = DxfDocument.Load(file);

}

Samples and Demos

Are contained in the source code.

Well, at the moment they are just tests for the work in progress.

Dependencies and distribution

.NET Framework 4.5. netDxf only references the NET libraries System.dll and System.Drawing.dll

Compiling

To compile the source code you will need Visual Studio 2015.

Development Status

See changelog.txt or the wiki page for information on the latest changes.

Supported entities

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)

All entities can be grouped.

All entities and table objects may contain extended data information.

AutoCad Table entities will be imported as Inserts (block references).

Both simple and complex line types are supported.

The library will never be able to read some entities like REGIONs, SURFACEs, and 3DSOLIDs, since they depend on undocumented proprietary data.

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
在DXF文件中,我们最关心的是如何得到模型上各个点的坐标,并且用这些点连成许多个三用形,构成面,进而绘制出整个模型。在DXF文件的结构中,我们已经看到,DXF文件先叙述实体上各个点的坐标,然后叙述实体上有多少个面,每个面由哪些点构成。这样,我们至少需要2个数组来存储一个实体的信息,一个用于存储点的坐标,一个用于存储点序,我们可以把这2个数组放到一个结构中,如果模型中实体的数目不止一个是,我们就用这个结构来定义一个数组。在本文中,我们使用      Visual C++ 6.0 来写一个读取DXF文件的小程序。     在实际应用中,模型中实体的数目以及实体中点和面的数目都是不定的,为了有效地利用内存,我们选择MFC类库中的聚合类CobArray类所创建的对象vertex,      sequence来存储和管理实体的点坐标和点序。     CObArray类是一个用来存放数组类的聚合类,它能根据要存进来的数组(或结构)多少自动进行自身大小的高速,而且这个类本身具有的成员函数使得我们对它的对象的操作更加方便、快捷,用它编的程序也易于读懂。     三维实体模型的模型信息中的一部分信息可以在标题段中读出,通过读取变量名为$UCSORG的三个变量,可以得到三维实体在世界坐标系中自身所定义的用户坐标系原点的三维坐标。通过读取$EXTMAX,$EXTMIN可以获知三维实体在世界坐标系中的范围,而其它部分的信息只有读完了全部DXF文件后才可以通过计算确定。对于三维实体模型的全部点坐标、点序,可以在实体段中按照前面介绍的DXF文件基本结构读出。现

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值