Search code examples
splineautodeskdxf

Creating DXF Spline programmatically


I need to create spline programmatically. I've made something like:

0
SECTION
  2
HEADER
  9
$ACADVER
  1
AC1006
  0
ENDSEC
  0
SECTION
  2
TABLES
  0
TABLE
2
LAYER
  0
LAYER
 2
shape
 70
 64
 62
 250
 6
CONTINUOUS
 0
LAYER
 2
holes
 70
 64
 62
 250
 6
CONTINUOUS
 0
ENDTAB
 0
ENDSEC
0
SECTION
2
ENTITIES
0
SPLINE
8
shape
100
AcDbSpline
210
0
220
0
230
1
70
4
71
3
72
11
73
4
74
4
42
0.0000001
43
0.0000001
44
0.0000000001
40
0
40
0
40
0
40
0
40
1
40
1
40
1
40
2
40
2
40
2
40
2
10
0
20
0
30
0
10
100
20
50
30
0
10
40
20
40
30
0
10
15
20
23
30
0
11
0
21
0
31
0
11
200
21
200
31
0
11
80
21
80
31
0
11
432
21
234
31
0
0
ENDSEC
0
EOF

When I'm trying to open it in Autodesk TrueView, I'm getting an error:

Undefined group code 210 for object on line 54. Invalid or incomplete DXF input -- drawing discarded.

Where is the error? When I'm copying just SPLINE section to the DXF generated by AI everything works fine. So I think I need to add something in the header section or something.


Solution

  • This file is DXF version AC1006 which is older than DXF R12. The SPLINE entity requires at least DXF version AC1012 DXF R13/R14. But with DXF version AC1012 the tag structure of DXF files is changed (OBJECTS and CLASSES sections, SubClassMarkers ...), so just editing the DXF version does not work.

    See also: http://ezdxf.readthedocs.io/en/latest/dxfinternals/filestructure.html#minimal-dxf-content

    Also the SPLINE entity seems to be invalid, it has no handle (5) and no owner tag (330), and the whole AcDbEntity subclass is missing.