Search code examples
fileformatdrawautocaddxf

Issue to duplicate Ellipse-Arc inside DXF file


I am trying to write a code to generate ellipse/arc using DXF file format. The number of ellipses depend on some parameters. I don't have issue to generate one ellipse or two. But when the number of ellipses increase, eventually the file gets corrupted.

I found out it's the name of the ellipse should follow a rule in naming which I am not sure what system autoCAD is using for the naming.

I extracted these names from the ellipes which were gernerated by autoCAD D1, D3, 87, 92, 98, 9E, A4, AA, B0m B6, BC, C2, C3, C9, CF, D5, D7, D9

my question is what system/rule does autoCAD use for the naming?

If you notice that autoCAD uses D1 in the first ellipse, and then D3

     0
ELLIPSE
  5
D1
330
70
100
AcDbEntity
  8
0
100
AcDbEllipse
 10
8.193371416945673
 20
6.584439091463058
 30
0.0
 11
0.0
 21
0.9445114593901811
 31
0.0
210
0.0
220
0.0
230
1.0
 40
0.9770115006281081
 41
3.141592653589792
 42
4.712388980384688
0
ELLIPSE
  5
D3
330
70
100
AcDbEntity
  8
0
100
AcDbEllipse
 10
8.193371416945673
 20
6.584439091463058
 30
0.0
 11
0.0
 21
0.9445114593901811
 31
0.0
210
0.0
220
0.0
230
1.0
 40
0.9770115006281081
 41
3.141592653589792
 42
4.712388980384688
     

Solution

  • Group code 5 (tag <5, D3>)defines an entity handle (text string with up to 16 hexadecimal digits) and must be unique for each entity in the DXF file. So you need to keep track of all the handles used in your DXF file (the STYLE entity uses group code 105 for the handle and is the only exception).

    AutoCAD is happy when you write the next available handle to the HEADER variable $HANDSEED, but does not require a valid entry to open the DXF file.

    See also: DXF Reference provided by Autodesk