1

I have a file with polygons representing building areas and an attribute table with a column for building height, I want to export to DXF polylines with the property "Thickness" filled in with the building height.

Can anyone help me with how to do this in QGIS? I know I can convert the polygons to lines in qgis and export to DXF and have it show as polylines but the attribute does not carry over.

3 Answers 3

1

This is a really good question, for which - i guess - there is no easy solution yet.

Because layer export depends on GDAL/OGR we can export style information, when we add a text column "OGR_STYLE" to our dataset. I.e. the value 'PEN(c:#FF0000)' sets the pen color to red. At the moment we can style some properties like colors, brushes, linestyles, symbols in DXF. Unfortunately, line width is not implemented (https://github.com/OSGeo/gdal/issues/3636).

Even adding EED (Extended Entity Data) is missing (https://github.com/OSGeo/gdal/issues/9472). With EED we could add arbitrary data to our polylines. I had similar requirements and had to generate my DXF manually via SQL, where I have all options.

BTW: you don't need to convert your polygons to linestrings, if you want to prevent hatches beeing created when exporting to DXF. Simply set the System Environment variable DXF_WRITE_HATCH=FALSE and your polygons are exported as polylines.

0

You could try to export your shape to DWG, or use the AutoCAD-addon spatial manager in order to import the shapefile with its attributes to CAD.

0

Here is some SQL code example to generate a DXF-Entities section for a POLYGON layer (enter code in DB Manager). To open the DXF in AutoCAD/BricsCAD, you have to prepend header.dxf and append trailer.dxf from GDAL first.

Sorry for adding the code as picture! ... always got an error while submitting the code as text.

enter image description here

I assumed that the table is called buildings and contains a column height.
Copy the result into a text file (i.e. temp.dxf) and remove the header line ("txt"). Then add header.dxf and trailer.dxf to your file. If you are on Windows you will find the files here: C:\OSGeo4W\apps\gdal\share\gdal.
Use the Command Line Interface to copy the files: COPY header.dxf + temp.dxf + trailer.dxf buildings.dxf. The polyline width will be automatically assigned by the height attribute.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.