📄 dxf.txt
字号:
Flag bit value Meaning
1 Extra vertex created by curve fitting
2 Curve fit tangent defined for this vertex.
A curve fit tangent direction of 0 may be
omitted from the DXF output, but is signif-
icant if this bit is set.
4 Unused (never set in DXF files)
8 Spline vertex created by spline fitting
16 Spline frame control point
32 3D Polyline vertex
64 3D polygon mesh vertex
SEQEND No fields. This entity marks the end of vertices (VERTEX
type name) for a Polyline, or the end of Attribute entities
(ATTRIB type name) for an INSERT entity that has Attributes
(indicated by 66 group present and nonzero in INSERT entity).
3DLINE 10, 20, 30 (start point), 11, 21, 31 (end point).
3DFACE Four points defining the corners of the face: (10, 20, 30),
(11, 21, 31), (12, 22, 32), and (13, 23, 33). 70 (invisible
edge flags -optional 0). If only three points were entered
(forming a triangular face), the third and fourth points will
be the same. The meanings of the bit-coded "invisible edge
flags" are shown in the following table.
Flag bit value Meaning
1 First edge is invisible
2 Second edge is invisible
4 Third edge is invisible
8 Fourth edge is invisible
DIMENSION 2 (name of pseudo-Block containing the current dimension pic-
ture), 10, 20, 30 (definition point for all dimension types),
11, 21, 31 (middle point of dimension text), 12, 22, 32
(insertion point for clones of a dimension (for BASELINE and
CONTINUE), 70 (Dimension type; 0=rotated, horizontal, or ver-
tical; 1=aligned; 2=angular; 3=diameter; 4=radius - the value
128 is added to this field if the dimension text has been
positioned at a user-defined location rather than at the
default location), 1 (dimension text explicitly entered by
the user. If null, the dimension measurement is drawn as the
text. Otherwise, this text is drawn (but if it includes the
sequence "<>", the dimension measurement is drawn in place of
the "<>")), 13, 23, 33 (definition point for linear and angu-
lar dimensions), 14, 24, 34 (definition point for linear and
angular dimensions), 15, 25, 35 (definition point for diame-
ter, radius, and angular dimensions), 16, 26, 36 (point
defining dimension arc for angular dimensions), 40 (leader
length for radius and diameter dimensions), 50 (angle of
rotated, horizontal, or vertical linear dimensions).
16
(C) Drawing Interchange and File Formats
In addition, all dimension types have an optional group (code
51) that indicates the "horizontal" direction for the Dimen-
sion entity. This determines the orientation of dimension
text and dimension lines for horizontal, vertical and rotated
linear dimensions. The group value is the negative of the
ECS angle of the UCS X axis in effect when the Dimension was
drawn. In other words, the X axis of the UCS in effect when
the Dimension was drawn is always parallel to the XY plane
for the Dimension's ECS, and the angle between the UCS X axis
and the ECS X axis is a single 2D angle. The value in group
51 is the angle from "horizontal" (the effective X axis) to
the ECS X axis. Entity Coordinate Systems (ECS) are
described later in this section.
For all dimension types, the following groups represent 3D
WCS points, regardless of the FLATLAND setting.
10, 20, 30
13, 23, 33
14, 24, 34
15, 25, 35
For all dimension types, the following groups represent ECS
points, and are 2D or 3D depending on the FLATLAND setting.
11, 21(, 31)
12, 22(, 32)
16, 26(, 36)
Linear (13,23,33) The point used to specify the first extension line.
(14,24,34) The point used to specify the second extension line.
(10,20,30) The point used to specify the dimension line.
Angular (13,23,33) and (14,24,34) The endpoints of the first line
(10,20,30) and (15,25,35) The endpoints of the second line
(16,26,36) The point used to specify the dimen-
sion line arc
Diameter (15,25,35) The point used to pick the circle/arc to dimension
(10,20,30) The point on that circle directly across from the
pick point.
Radius (15,25,35) The point used to pick the circle/arc to dimension
(10,20,30) The center of that circle.
17
AutoCAD Reference Manual
Entity Coordinate Systems (ECS)
To save space in the drawing database (and in the DXF file), the points
associated with each entity are expressed in terms of its own Entity Coor-
dinate System (ECS). The Entity Coordinate System allows AutoCAD to use a
much more compact means of representation for entities. With ECS, the only
additional information needed to describe its position in 3D space is the
3D vector describing the Z axis of the ECS, and the elevation value.
For a given Z axis (or extrusion) direction, there is an infinite number of
coordinate systems, defined by translating the origin in 3D space and by
rotating the X and Y axes around the Z axis. However, for the same Z axis
direction, there is only one Entity Coordinate System. It has the follow-
ing properties:
o Its origin coincides with the WCS origin.
o The orientation of the X and Y axes within the XY plane are calcu-
lated in an arbitrary, but consistent manner. AutoCAD performs
this calculation using the "arbitrary axis" algorithm described
below.
For some entities, the ECS is equivalent to the World Coordinate System and
all points (DXF groups 10-37) are expressed in World coordinates. See the
following table.
Entities Notes
LINE, POINT, 3DFACE, 3D These entities do not lie in
Polyline, 3D Vertex, 3D a particular plane. All
Mesh, 3D Mesh vertex points are expressed in
World coordinates. Of these
entities, only Lines and
Points can be extruded;
their extrusion direction can
differ from the World Z axis.
CIRCLE, ARC, SOLID, TRACE, These entities are planar in
TEXT, ATTRIB, ATTDEF, SHAPE, nature. All points are
INSERT, 2D Polyline, 2D expressed in Entity coordi-
Vertex nates. All these entities
can be extruded; their
extrusion direction can
differ from the World Z axis.
DIMENSION Some of a Dimension's points are
expressed in WCS, and some in ECS.
Others The remaining entities have
no point data and their
coordinate systems are
therefore irrelevant.
Once AutoCAD has established the ECS for a given entity, here's how it
works:
18
(C) Drawing Interchange and File Formats
o The elevation value stored with an entity indicates how far along
the Z axis to shift the XY plane from the WCS origin to make it
coincide with the plane that the entity is in. How much of this
is the user-defined elevation is unimportant.
o Any 2D points describing the entity that were entered through the
UCS are transformed into the corresponding 2D points in the ECS,
which (more often than not) is shifted and rotated with respect to
the UCS.
A few ramifications of this process are:
o You can not reliably find out what UCS was in effect when an
entity was acquired. You can only find out where the entity is in
the current UCS if the current UCS has the same Z axis direction
as the original UCS (i.e., they both reduce to the same ECS).
o When you enter the XY coordinates of an entity in a given UCS and
then do a DXFOUT, you probably won't recognize those XY coordi-
nates in the DXF file. You'll have to know the method by which
AutoCAD calculates the X and Y axes in order to work with these
values.
o The elevation value stored with an entity and output in DXF files
will be a sum of the Z coordinate difference between the UCS XY
plane and the ECS XY plane, and the elevation value that the user
specified at the time the entity was drawn.
Arbitrary Axis Algorithm
The arbitrary axis algorithm is used by AutoCAD internally to implement the
"arbitrary but consistent" generation of Entity Coordinate Systems for all
entities except Lines, Points, 3D Faces, and 3D Polylines, which contain
points in World coordinates.
Given a unit-length vector to be used as the Z axis of a coordinate system,
the arbitrary axis algorithm generates a corresponding X axis for the coor-
dinate system. The Y axis follows by application of the right hand rule.
The method is to examine the given Z axis (also called the normal vector)
and see if it is close to the positive or negative World Z axis. If it is,
cross the World Y axis with the given Z axis to arrive at the arbitrary X
axis. If not, cross the World Z axis with the given Z axis to arrive at
the arbitrary X axis. The boundary at which the decision is made was
chosen to be both inexpensive to calculate and completely portable across
machines. This is achieved by having a sort of "square" polar cap, the
bounds of which is 1/64, which is precisely specifiable in 6 decimal frac-
tion digits and in 6 binary fraction bits.
In mathematical terms, the algorithm does the following (all "vectors" are
assumed to be in 3D space, specified in the World Coordinate System).
Let the given normal vector be called N.
Let the World Y axis be called Wy, which is always (0,1,0).
Let the World Z axis be called Wz, which is always (0,0,1).
19
AutoCAD Reference Manual
We are looking for the arbitrary X and Y axes to go with the normal N.
They'll be called Ax and Ay. N could also be called Az (the arbitrary Z
axis).
If (Nx < 1/64) and (Ny < 1/64) then
Ax = Wy * N (where "*" is the cross-product operator).
Otherwise,
Ax = Wz * N.
Scale Ax to unit length.
The method of getting the Ay vector would be:
Ay = N * Ax.
Scale Ay to unit length.
C.1.6 Writing DXF Interface Programs
Writing a program that communicates with AutoCAD via the DXF mechanism
often appears far more difficult than it really is. The DXF file contains
a seemingly overwhelming amount of information, and examining a DXF file
manually may lead to the conclusion that the task is hopeless.
However, the DXF file has been designed to be easy to process by program,
not manually. The format was constructed with the deliberate intention of
making it easy to ignore information you don't care about while easily
reading the information you need. Just remember to handle the groups in
any order and ignore any group you don't care about, and you'll be home
free.
As an example, the following is a Microsoft BASIC program that reads a DXF
file and extracts all the LINE entities from the drawing (ignoring lines
that appear inside Blocks). It prints the endpoints of these lines on the
screen. As an exercise you might try entering this program into your com-
puter, running it on a DXF file from one of your drawings, then enhancing
it to print the center point and radius of any circles it encounters. This
program is not put forward as an example of clean programming technique nor
the way a general DXF processor should be written; it is presented as an
example of just how simple a DXF-reading program can be.
1000 REM
1010 REM Extract lines from DXF file
1020 REM
1030 G1% = 0
1040 LINE INPUT "DXF file name: "; A$
1050 OPEN "i", 1, A$ + ".dxf"
1060 REM
1070 REM Ignore until section start encountered
1080 REM
1090 GOSUB 2000
1100 IF G% <> 0 THEN 1090
1110 IF S$ <> "SECTION" THEN 1090
20
(C) Drawing Interchange and File Formats
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -