0

I am using ezdxf to generate a DXF file for a tool. This tool needs to have in the dxf a comment containing informations for each layer. The comments must be formatted in a particular way.

Is there a way to create a comment and save it with ezdxf

NB: Currently I use a "dirty" hook to do this

I create an XDATA with a MYAPP ID for each layer with :

layer.set_xdata (myapp_id, [(999, comment)]) 

then I save the dxf file with

doc.saveas ("./ my_dxf_file.dxf")

after with a python script I delete all the occurrences 1001 \ nMYAPP_DATA \ n in the dxf file to keep only the 999 tags (otherwise autocadLT cannot read the file... others tools like nanocad or babacad can but not autocadLT)

Stewbob
  • 16,759
  • 9
  • 63
  • 107
phil
  • 1

1 Answers1

0

See documentation for set/get layer description as property:

layer.description = 'your comment'

mozman
  • 2,001
  • 8
  • 23
  • Thank you very much for this very quick response. I immediately tested but unfortunately it wrote the comment in a dxf 1000 or tag the application which uses the generated dxf (and which I cannot modify) waits for the comment in a tag 999 (which if I am not mistaken is a tag to describe a comment) is there any other solution? – phil Apr 22 '20 at 14:02
  • This is the undocumented but by AutoCAD supported way to store layer descriptions. The 999 tag is the DXF comment tag and is ignored by most applications and also by ezdxf, it is not meant to store 3rd party application data, there are really many (more or less) documented ways to store 3rd party data in DXF files. ezdxf does not support any way to store DXF comments at all, except by ugly hacks. – mozman Apr 22 '20 at 14:57