I would like to convert the drawings inside a .dxf file into g-code. There are tools doing that but I would like to code it myself. So, the very first part is to decode the .dxf format.
I downloaded a .dxf file here and opened it in a "text editor". I am also referring to this manual. It looks like what is inside a .dxf file is mostly style and configuration information and I tend to omit almost everything.
The actual information about the coordinates seems to be at the SECTION
of ENTITIES
. I am copy-pasting this section below. There are two LWPLOYLINES
where 10
represents X positions and 20
represents Y positions of the vertices. 42
represents some information about bulge in the figure.
The question is, what should I take into consideration -other than the coordinates- while converting the dxf format into G-code? Also, I don't know where this information is stored in a dxf file.
What comes to my mind are:
- Units, i.e. meters, millimeters, inches
- Offset, i.e. according to (0,0) point
- Scale ratio, i.e 1:8, 1:100 etc.
So, what fields should I know to be able to obtain an accurate G-code from the dxf file and where are these fields located inside the file? Thank you.
0
SECTION
2
ENTITIES
0
LWPOLYLINE
5
72
330
1F
100
AcDbEntity
8
Layer 1
100
AcDbPolyline
90
12
70
1
43
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