AutoCAD的DXF⽂件格式及其转换接⼝研究
AutoCAD的DXF⽂件格式及其转换接⼝研究
张成才孙喜梅 朱陶业
摘 要 详细研究了Auto CAD的D XF⽂件数据格式,分析DXF⽂件的组成,设计了将DXF格式转换为⽤户计算程序所需的数据格式和⽤户数据转换为DXF⽂件格式接⼝程序的功能及其框图。
关键词 计算机辅助设计 数据格式 地理信息系统
⼀、引⾔
计算机辅助设计(Co mputer A ided D esign简写为:CA D)是⼀种以计算机硬、软件系统辅助⼈们进⾏产品或⼯程设计的技术。
A ut oCA D是由美国A utodesk公司推出的通⽤交互式绘图软件,在P C机上⼴为流⾏,是当今世界上使⽤最⼴泛的CA D软件之⼀。DXF是A utoCA D的绘图互换格式(D raw ing Interchange F or mat),这种交换格式得到其他CAD 程序的⼴泛⽀持,甚⾄得到其他计算机平台的⽀持,该标准的公布于众,对于⾮CA D应⽤程序存取⼯程绘图有很⼤的价值。它具有⼀种⽮量格式所具有的全部优点,再加上作为3-D⽮量格式的
优点,因此可以处理真3-D形状,包括线框和实平⾯。在地理信息系统的设计中,经常⽤到对扫描图形的⽮量化、绘制各种各样的图形、符号以及标记,许多商⽤GIS软件在这⽅⾯功能还不太强,⽽Auto CAD在这⽅⾯具有很强的功能,⼆者可以通过DXF⽂件进⾏相互转换,使G IS系统利⽤A utoCA D的这些功能。
⼆、DXF⽂件格式概述
DXF⽂件有两种格式:A SCI I和⼆进制。前者较易阅读,后者则占较少的空间且装⼊速度较快。
DXF⽂件分成多个节(SECT ION),每个节均由多个组(G RO U P)组成。
Gr o up:
 GR OU P COD E
 GR OU P V A LU E
每⼀组都有⼀个组代码,后⾯是⼀个称为组值的数字或字符串。在每个节中由⼀个组值为SECT ION的0组开始,后跟组值为表⽰节名的字符串的2组,其后为组成该节的各个组,最后以组值为字符串SN DSEC的0组表⽰该节结束。
组码是⼀个A SCII整数(⼆进制D XF中为⼆进制),指⽰后⾯跟的值的类型。组码的特定范围为特定类型的数值⽽保留。例如,范围0-9的组码表⽰后⾯跟的是⼀个A SCII字符串;特定的码指该字符串⽤于什么。组码和组值之间⽤⼀个回车/换⾏字符对分开。
D XF⽂件中的数据按照下列⽅法组织: HEA DER节:包括的⼤部分信息对⾮CA D应⽤程序来说没有任何价值,许多信息是与⽂本和定尺⼨有关的。
T A BL ES节:定义特定的通⽤常量,如绘图“层”(Lay er)、观察⾓度和距离、坐标系统以及尺⼨风格。像HEA DER节⼀样有时也可以忽略。
BL O CK S节:按名字定义实体组,同时也可以包含实体。现在它还没有得到⼴泛使⽤,但由于它允许绘声的模块化,所以正越来越流⾏。
ENT IT I ES节:通过使⽤点、线、圆、弧等定义实际的三维或⼆维⼏何体(实体),并包括把实体的层或块连接的数据。它是实体交换的主要节。
在DXF⽂件的最后是组值为字符串EO F(End of F ile)的0组作为⽂件的结束标志。
三、DXF⽂件组成
1.HEADER节
HEA DER节定义头变量,在Auto CAD14版中就有160多个头变量。因HEAD ER节对⾮CA D应⽤程序没有影响,这⾥不再赘述,仅举⼀例。⼀个典型的DX F⽂件以HEA DER 节开始,如:
SECT IO N
2
HEA DER
9
$CECO L OR
62
END SEC
2.TABLES节
在DX F⽂件的T A BL ES节中,有各种不同类型的表,每个表⼜包含了可变数⽬的表项。⽤于交换图形信息的主要有LT Y PE(线型)、L A Y ER(图层)、ST YL E(字样)、VI EW(视
张成才 长沙电⼒学院数学与计算机系 副教授 博⼠后 长沙 410077
图)表。这些表可以有任意多个,⽽且他们可以以任何顺序出现。T A BLES节的结构如下:
SECT IO N
2
T A BL ES
……
(各个单独的表)
……
EN DSEC
单个表的结构如下:
T A BL E
2
(表类型号,如L A Y ER)
70
(后跟表项的最⼤数⽬)
(⼜⼀个表类型名,如L A Y ER)
2
(⽤户赋值的名字或数字,如W IRI NG)gis字符串是什么
(各种组码和值)
……
EN DT A B
3.BLOCKS节
⼀个DXF⽂件的BLO CK S节,记录了定义每⼀个块时的块名、当前图层名、块的种类、块的插⼊基点及组成该块的所有成员。块⼜可分为图形块、带有属性的块和⽆名块三种。⽤HA T CH命令⽣成的剖⾯线和⽤DI M命令⽣成的尺⼨标注包含在⽆名块中。⼀个BL OCK S节按下列⽅式组织: 0
SECT IO N
2
BL O CK
BL O CK
2
(⽤户赋值的块名)
70
(忽略)
……
(单独实体)
……
END BL O CK
END SEC
4.ENTITIES节
这个节是实际⼏何信息存在的地⽅,并构成DXF⽂件的主题。EN T I T IES节记录了每个实体的名字,所有图层的名字、线型号、颜⾊号、基⾯⾼度、厚度以及有关的⼏何数据。ENT IT I ES节按下列⽅式组织:
SECT IO N
2
……
(单独实体)
……
END SEC
⼏乎实体主要有:P OI NT,L IN E,CI RCL E,A RC, T RA CE,SOL ID,P OL Y L IN E,VER T EX和SEQ U EN D以及3DF A CE。
单个实体的格式为:
(实体名,如L IN E)
8
(⽤A SCII表⽰的层名或数字,如0)
(相关的组码和值)
四、DXF⽂件接⼝程序
A uto CA D把图形输出成DXF格式⽂件,以便其他程序读取、分析、加⼯和处理;其他程序也可以按照规定的格式⽣成D XF⽂件,A utoCA D可以接受该DX F⽂件并转换成图形。
在A utoCA D中DXF⽂件是由DXF IN(读⼊)和DXF OU T(输出)命令调⽤或输出的,尽管DXF⽂件是A SCII ⽂本⽂件,但是⼈⼯来阅读或编写⽂件清单,效率和可靠性都是很低的。
DXF⽂件的接⼝程序可以胜任将图形转换成数据读取DXF⽂件中有⽤信息的⼯作。
1.将计算数据转换为DXF格式
将⽤户数据转换为DX F⽂件格的过程,如图1
所⽰。
(未完待续)
Microcomputer Applications Vol.17,No.8,2001 ABSTRACTS&KEYWORDS 微型电脑应⽤ 2001年第17卷第8期Keywords C# .NET relational database
…………………………………………
A Scientif ic and Technological Information Management System Based on TRS API P48 Feng Y ali M a X ianJ un(D ep ar tment of Comp uter S cience and T echnology,Daqing P etr oleum Colleg e A nd a151400) Abstract T his paper intro duces br iefly T RS and descr ibes in detail pr og ramming using T RS AP I w ith C++Builder3.0as it s fr ont-end dev elo pment t oo l.A Scientific and T echnolo gical Infor mation System fo r Da qing Qilfield is illustr ated as an ex ample. Keywords  T RS DM S T RS A PI infor matio n maintenance info r matio n r etr iev al
A Solution to Real Time Measurement and C ontrol in V
B P50
………………………………………………………………………
L u Zhicai Shang Y anli(D ep ar tment of com p uter science and technology,N ankai U niv er sity N anj ing300071)
Abstract T he m ultim edia timer ca n pr ovide high accur acy timing.A nd multithr eading can impro ve r eal-tim e pr ocessing due to parallelism.T heir combination is the best so lut ion to real-t ime meas
urement and contr ol in V B.T his paper illust rates this solutio n as w ell as some technical pr oblems by an applicatio n sam ple w ith its pro g ram seg ment s.
Keywords V B measur ement and co nt ro l pro gr am r eal time multimedia timer multit hr ead
…………………………………………………………………………………………………Verilog HDL Applied Modern EDA P52 Zhang x ia(H ankou B ranch,H uaz hong University of S cience and T echnology W uhan430012)
Abstract T his paper sho ws the pro cess o f electr onic desig n a uto mation and illustr ates Ver ilog HDL applicatio n by an ex ample. Wa vefor ms of log ic funct ion simulatio n and time ana ly zer simula tio n ar e show n in a co mparat ive w ay. Keywords V er ilog HD L ED A lo gic funct ion simulatio n time analyzer simulation ……………………………………………………………………AutoCAD's DXF File Format and Its Transforming Interface P54 Zhang Chengcai S un X imei Zhu T aoy e(D ep artment of M athematics and Comp uter S cience,S hang sha Univ er sity of Electr ical Pow er Changsha410077)
Abstract T he A uto CAD's DX F file for mat is discussed and analyzed in det ail.T he desig n diag ra m and functio ns of an inter face for tr ansfo rm ing DX F file fo rmat into t he o ne required by the user
pro g ram and vice v ersa ar e also illustr ated. Keywords CA D data fo rmat geo gr aphical info rmat ion system
Optimization of Network-Based Virtual Scenes P56
……………………………………………………………………………………
L in D ongmei Zhu Y ux i W ang D ong(Dep ar tment of Com p uter Science,D aqing Petroleum College A nda151400)
Abstract T his paper discusses pr oblems of creat ing lar g e v irt ual scenes based on the netw or k using V RM L,a nd pr oposes a solutio n t o r aising the speed of pr oducing scenes and sho rtening the time of dow nlo ading files for it.F act or s invo lv ing t he pro ducing speed w it h V R M L are also g iv en.
Keyword vir tual realit y virt ual scene r eal time display tex ture mapping
Learners'Garden
…………………………………………………………………………………How to C reate Query Forms in
Visual FoxPro?P59 W ang D ux iang(T eaching and Resear ch S ection of Com p uter,Bengbu N avy S chool B engbu233012) W ei X ianbin(B engbu T echnological Quality S up erv ision T eam Beng bu233012)
Abstract T his paper intro duces how to use Visual Fo x Pr o6.0to cr eate g ener al query fo rm s.T he desig n o f contr ols as w ell as their codes a re also g iven.
Keywords g eneral poll fo rm co nt ro l
…………………………………………………………How to Perform Transaction Processing of the Database With ADO?P61 W an Chun(N etw or king Center,J imei U niver sity X iamen361021)
Abstract T his paper intro duces the method of per for ming t ransactio n pr ocessing w ith A DO.I t pr ov es effect ive in pr actice. Keywords tr ansactio n pr ocessing A DO AD O data contr ol
…………………………………………………………………………………How to Modif y AutoCAD Documents Using VB?P63 Sun Zhi M eng X iangz hong(R&D Center,X iaoy a Gr oup J inan250101)
Abstract T his paper intr o duces the metho d of mo difying Auto CAD do cuments using Visual Basic.An ex ample of mo difying an upper frame is g iv en.
Keywords A uto CA D V B upperfr ame
Address: Room1504,Flo or15,Bao Zhaolong Library,Shang hai Jiaotong U niversity
1954Huashan Road,Shang hai200030,The People's Republic of China
Tel:86-21-62933230 Fax:86-21-62933230 Em ail:smcaa@www.doczj/doc/1b6dfc55ba1aa8114531d917.html URL:http//w www.doczj/doc/1b6dfc55ba1aa8114531d917.html IP:202.96.210.198
Publisher:Shang hai Microco mputer Application Association Co d e Num ber:6329M
Distr ibuto r:China International Book T rading Corporatio n(P.O.Box399,Beijing)

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。