如何解码 .dxf 文件?
How to decode .dxf files?
我想将 .dxf 文件中的绘图转换为 g 代码。有工具可以做到这一点,但我想自己编写代码。因此,第一部分是解码 .dxf 格式。然而,.dxf 文件的内容看起来并不容易破译。
我下载了一个 .dxf 文件 here 并在文本编辑器中打开它。
我也指这个manual。看起来 .dxf 文件中的内容主要是样式和配置信息,我倾向于忽略几乎所有内容。所以,1。你能指定不应省略的属性吗?
据我所知,这些数字在 .dxf 文件中分为多个实体。因此,我只是复制粘贴实体部分。请注意,文件中有 6 个部分,最后一节(BLOCKS OBJECTS)是最长的,尽管我不知道那部分代表什么(如果你能解释一下会很好) .
在下面的代码中,10 和 20 应该代表 X 和 Y 位置,42 应该代表凸起。可以跟踪多段线。我考虑通过使用 TITLES 作为导航点以及 10、20 和 42 等数字从文件中提取信息。但是下面有两条折线。所以,2。我应该考虑哪条折线,另一条的目的是什么?
0
SECTION
2
ENTITIES
0
LWPOLYLINE
5
72 # What
330 # are
1F # these
100 # numbers?
AcDbEntity
8
Layer 1
100
AcDbPolyline
90
12
70
1
43 # Constant width (optional; default = 0)
0.0
10
11.7511418685121
20
14.9867256637168
42
1.0
10
3.31114186851211
20
14.9867256637168
10
-0.0132743362831871
20
14.9867256637168
10
-0.0132743362831871
20
11.72
42
1.0
10
-0.0132743362831871
20
3.28
10
-0.0132743362831871
20
0.0398230088495577
10
3.28
20
0.039823008849557
42
1.0
10
11.72
20
0.0398230088495577
10
15.0132743362832
20
0.0398230088495577
10
15.0132743362832
20
3.28
42
1.0
10
15.0132743362832
20
11.72
10
15.0132743362832
20
14.9867256637168
0
LWPOLYLINE
5
73
330
1F
100
AcDbEntity
8
Layer 1
100
AcDbPolyline
90
12
70
1
43
0.0
10
12.6544611051008
20
15.9867256637168
10
16.0132743362832
20
15.9867256637168
10
16.0132743362832
20
12.6233192365887
42
-0.823684764724874
10
16.0132743362832
20
2.37668076341128
10
16.0132743362832
20
-0.960176991150442
10
12.6233192365887
20
-0.960176991150442
42
-0.823684764724874
10
2.37668076341128
20
-0.960176991150443
10
-1.01327433628319
20
-0.960176991150442
10
-1.01327433628319
20
2.37668076341128
42
-0.823684764724874
10
-1.01327433628319
20
12.6233192365887
10
-1.01327433628319
20
15.9867256637168
10
2.40782263192339
20
15.9867256637168
42
-0.823684764724874
0
ENDSEC
相关问题
- What fields to take into consideration in a .dxf file to obtain an accurate G-Code?
The last section (BLOCKS
) is the longest one although I don't know
what that part represents (Would be nice if you could explain).
BLOCKS
部分的用途总结在您提到的手册中:
The BLOCKS
section contains an entry for each block reference in the drawing.
将块视为一组实体,这些实体组合在一起作为一个元素。该块有:
- 来源
- 旋转
- 规模
此类块在绘图本身中被引用,块的每个实例被称为INSERT
。
所以当你走过 ENTITIES
部分并碰到一个 INSERT
实体时,你必须在 [=16= 中找到它的 handle ] table 并相应地处理元素。
有一些 DXF 代码对许多实体都是通用的,它们并不总是与特定实体类型的信息一起列出(例如 LWPOLYLINE
)。
看看这个 complete list 这些数字:
5: Entity handle; text string of up to 16 hexadecimal digits (fixed)
330: Soft-pointer handle; arbitrary soft pointers to other objects within same DXF file or drawing. Translated during INSERT
and XREF
operations
100: Subclass data marker (with derived class name as a string). Required for all objects and entity classes that are derived from
another concrete class. The subclass data marker segregates data
defined by different classes in the inheritance chain for the same
object. This is in addition to the requirement for DXF names for each
distinct concrete class derived from ObjectARX (see Subclass Markers)
这个page也很有用
Why are there 2 LWPOLYLINES
in the first place and why is it not only one BLOCK
-ENDBLK
pair?
如果您通读有关 BLOCKS
的部分,您会看到:
Model Space and Paper Space Block Definitions
Three empty definitions always appear in the BLOCKS
section. They are
titled *Model_Space
, *Paper_Space
and *Paper_Space0
. These definitions
manifest the representations of model space and paper space as block
definitions internally. The internal name of the first paper space
layout is *Paper_Space, the second is *Paper_Space0, the third is
*Paper_Space1, and so on.
我想将 .dxf 文件中的绘图转换为 g 代码。有工具可以做到这一点,但我想自己编写代码。因此,第一部分是解码 .dxf 格式。然而,.dxf 文件的内容看起来并不容易破译。
我下载了一个 .dxf 文件 here 并在文本编辑器中打开它。
我也指这个manual。看起来 .dxf 文件中的内容主要是样式和配置信息,我倾向于忽略几乎所有内容。所以,1。你能指定不应省略的属性吗?
据我所知,这些数字在 .dxf 文件中分为多个实体。因此,我只是复制粘贴实体部分。请注意,文件中有 6 个部分,最后一节(BLOCKS OBJECTS)是最长的,尽管我不知道那部分代表什么(如果你能解释一下会很好) .
在下面的代码中,10 和 20 应该代表 X 和 Y 位置,42 应该代表凸起。可以跟踪多段线。我考虑通过使用 TITLES 作为导航点以及 10、20 和 42 等数字从文件中提取信息。但是下面有两条折线。所以,2。我应该考虑哪条折线,另一条的目的是什么?
0
SECTION
2
ENTITIES
0
LWPOLYLINE
5
72 # What
330 # are
1F # these
100 # numbers?
AcDbEntity
8
Layer 1
100
AcDbPolyline
90
12
70
1
43 # Constant width (optional; default = 0)
0.0
10
11.7511418685121
20
14.9867256637168
42
1.0
10
3.31114186851211
20
14.9867256637168
10
-0.0132743362831871
20
14.9867256637168
10
-0.0132743362831871
20
11.72
42
1.0
10
-0.0132743362831871
20
3.28
10
-0.0132743362831871
20
0.0398230088495577
10
3.28
20
0.039823008849557
42
1.0
10
11.72
20
0.0398230088495577
10
15.0132743362832
20
0.0398230088495577
10
15.0132743362832
20
3.28
42
1.0
10
15.0132743362832
20
11.72
10
15.0132743362832
20
14.9867256637168
0
LWPOLYLINE
5
73
330
1F
100
AcDbEntity
8
Layer 1
100
AcDbPolyline
90
12
70
1
43
0.0
10
12.6544611051008
20
15.9867256637168
10
16.0132743362832
20
15.9867256637168
10
16.0132743362832
20
12.6233192365887
42
-0.823684764724874
10
16.0132743362832
20
2.37668076341128
10
16.0132743362832
20
-0.960176991150442
10
12.6233192365887
20
-0.960176991150442
42
-0.823684764724874
10
2.37668076341128
20
-0.960176991150443
10
-1.01327433628319
20
-0.960176991150442
10
-1.01327433628319
20
2.37668076341128
42
-0.823684764724874
10
-1.01327433628319
20
12.6233192365887
10
-1.01327433628319
20
15.9867256637168
10
2.40782263192339
20
15.9867256637168
42
-0.823684764724874
0
ENDSEC
相关问题
- What fields to take into consideration in a .dxf file to obtain an accurate G-Code?
The last section (
BLOCKS
) is the longest one although I don't know what that part represents (Would be nice if you could explain).
BLOCKS
部分的用途总结在您提到的手册中:
The
BLOCKS
section contains an entry for each block reference in the drawing.
将块视为一组实体,这些实体组合在一起作为一个元素。该块有:
- 来源
- 旋转
- 规模
此类块在绘图本身中被引用,块的每个实例被称为INSERT
。
所以当你走过 ENTITIES
部分并碰到一个 INSERT
实体时,你必须在 [=16= 中找到它的 handle ] table 并相应地处理元素。
有一些 DXF 代码对许多实体都是通用的,它们并不总是与特定实体类型的信息一起列出(例如 LWPOLYLINE
)。
看看这个 complete list 这些数字:
5: Entity handle; text string of up to 16 hexadecimal digits (fixed)
330: Soft-pointer handle; arbitrary soft pointers to other objects within same DXF file or drawing. Translated during
INSERT
andXREF
operations100: Subclass data marker (with derived class name as a string). Required for all objects and entity classes that are derived from another concrete class. The subclass data marker segregates data defined by different classes in the inheritance chain for the same object. This is in addition to the requirement for DXF names for each distinct concrete class derived from ObjectARX (see Subclass Markers)
这个page也很有用
Why are there 2
LWPOLYLINES
in the first place and why is it not only oneBLOCK
-ENDBLK
pair?
如果您通读有关 BLOCKS
的部分,您会看到:
Model Space and Paper Space Block Definitions
Three empty definitions always appear in the
BLOCKS
section. They are titled*Model_Space
,*Paper_Space
and*Paper_Space0
. These definitions manifest the representations of model space and paper space as block definitions internally. The internal name of the first paper space layout is *Paper_Space, the second is *Paper_Space0, the third is *Paper_Space1, and so on.