Unfortunately, none of the approaches provides a simple method, but this is possible with little effort.
With a DWG file, the file itself is binary, so it’s best to write a plugin or script in AutoCAD using .NET or ObjectArx, but this can be a nasty approach. AutoLISP would be simpler, but I don't think you could output it to a file.
enitity DXF , DXF - . , , . DXF - AutoDESK. XData, , DXF , .