Open basilrabi opened 4 years ago
This issue is still valid on QGIS 3.16.15 and 3.22.2.
same still bug on windows
Someone found a Workaround?
I tried to use GDALs convertformat for exporting a shp to dxf.
If i export it direct to the disc it does not include attributes. If i use the Tool and save to temporary Layer the attributes are within the attributetable. But of course it isnt a dxf. If i try to export this temporary Layer with right-click -> Again no attributes exported.
This seems to be a limitation of the DXF format wherein limited fields are available (e.g. layer name, color, etc). I created my own processing plugin using ezdxf to export layers using some field as dxf layer name.
While QGis May have a bug here, please note the following:
GDAL's DXF Vector format only supports "Text" for point geometries having defined style. From docs:
Point features with LABEL styling are written as MTEXT entities based on the styling information.
Point features without LABEL styling are written as POINT entities.
Here, "LABEL styling" must complain with:
And should be specified using "OGR_STYLE" column
That said, code used from CLI - instead of the proposed by @basilrabi - should be:
ogr2ogr \
-f DXF output_file.dxf \
PG:"service=example_service" \
-sql "SELECT 'LABEL(t:''' || text_field || ''')' AS ogr_style, text_field AS \"Text\", geom FROM some.table"
You can check your results using
ogrinfo -so output_file.dxf entities
Describe the bug
Layer attributes are not exported in dxf (even if they are valid dxf attributes). In the attached project file, the layer has 2 fields:
but neither are exported in dxf. Also, when Exporting Labels as MTEXT elements in exporting project as dxf, no labels seem to be exported.
How to Reproduce
TLDR
Method 1
Method 2
QGIS and OS versions
Additional context
I tried importing the layer to postgis then exporting it to dxf using
ogr2ogr
. The attribute "Layer" is exported but the attribute "Text" is still empty. The command I used:ogr2ogr -f "DXF" export.dxf PG:"host=localhost dbname=r user=tmcgis" -sql "SELECT * FROM mylayer"