gdal icon indicating copy to clipboard operation
gdal copied to clipboard

DXF driver: ogr2ogr created DXF file lacks the OGR Feature Style LABEL's background/outline color

Open faridcher opened this issue 4 years ago • 5 comments

echo a,b > dummy.csv
# A LABEL's foreground color (c:#B3B3B3) is set to gray and works as expected. The color is translated into an index number (253) with group code 62 in the DXF file.
\ogr2ogr -dialect sqlite \
  -sql 'select "LABEL(f:Arial,t:OGR2OGR,c:#B3B3B3)" OGR_STYLE, GeomFromText("POINT(0 0)") geom' \
  b.dxf dummy.csv

# However, ogr2ogr DXF driver withholds the application of the background color (b:#B3B3B3) to the MTEXT entity.
\ogr2ogr -dialect sqlite \
  -sql 'select "LABEL(f:Arial,t:OGR2OGR,b:#B3B3B3)" OGR_STYLE, GeomFromText("POINT(0 0)") geom' \
  b.dxf dummy.csv

# The expected output DXF should look like this. 63 DXF code is for bg color and 90 is to enable it
sed 's/AcDbMText/&\n 63\n253\n 90\n1/' b.dxf > b2.dxf

the same problem presists with a LABEL outline color.

ogr2ogr --version GDAL 3.2.2, released 2021/03/05

faridcher avatar Apr 04 '21 08:04 faridcher

CC @atlight

rouault avatar Apr 04 '21 09:04 rouault

The docs are clear that b is not supported in style strings. This support can easily be added as a copy-paste of https://github.com/OSGeo/gdal/blob/814434983f73c2917ceb36ee8a72fa3225ce646c/gdal/ogr/ogrsf_frmts/dxf/ogrdxfwriterlayer.cpp#L514-L519 with appropriate changes - not a hard change to make, but I won't have time to address it in the immediate future.

atlight avatar Apr 04 '21 10:04 atlight

any news on this? Is there any other way to get the style from dxf?

pcace avatar Jan 07 '25 11:01 pcace

@pcace I ended up writing a sed/awk script to manipulate the output DXF. To give you an idea,

/^ 62$/{N; s# 62\n253# 63\n253\n 90\n1# }

it sets the bg color to gray. Mind the #, which is used as sed s command delimiter.

faridcher avatar Jan 08 '25 04:01 faridcher

For hatch, reading/setting the background color will be handled per https://github.com/OSGeo/gdal/pull/12735

rouault avatar Jul 10 '25 20:07 rouault