Looking for an open source solution to extract CAD annotations to one or several common OGR vector formats (DXF, Geopackage, shapefile ..). Output data must contains at least text and rotation.
QGIS has a plugin named, dxf2shape. There is an option to convert Cad Text to shapefile Points. Each point will be located at the Text origin and contain the Cad Text string in an attribute. Shapefiles cannot store Annotation.
QGIS 3.x comes with an in built dwg to gpkg converter under Project > Import (something like that, will edit this comment). This saves you the step of needing another program to save the dwg as a dxf.
After playing a bit ... OGR does have solutions to extract more informations from DXF.
Using OGR_STYLE with ogrinfo/ogr2ogr CLI
ogrinfo PROJET.dxf -sql "select OGR_STYLE from entities where Layer = '3ZONCOMMTEX'"
Style = LABEL(f:"Arial",t:"Route",p:1,a:32.1,s:2.5g,c:#000000)
GetStyleString() function (OGR Python Binding)
import ogr driver = ogr.GetDriverByName("DXF") source = driver.Open("PROJET.dxf") layer = source.GetLayer() fields = layer.GetLayerDefn() for feat in layer: style = feat.GetStyleString() print(style) # LABEL(f:"Arial",t:"Route",p:1,a:32.1,s:2.5g,c:#000000)