TransWikia.com

Exporting to DXF using Python doesn't give layername compared to using QGIS File export

Geographic Information Systems Asked by GladH on May 5, 2021

I’m trying to export a DXF file with python in QGIS, but I get different results when I use "Project->Import/export->Export project to DXF…-> and then export to a DXF file"

Compared to my Python script, the export works fine and I get a DXF file which contains all information except the layer name.

When I place the DXF file in my CAD program the one I make with python does not contain the layer name. While the one I export using "Project->Import/export->Export project to DXF…-> and then export to a DXF file" does.

Export using Project-> etc.

Below is the python code i’m using

Does anyone know if this is possible using Python?

output_name ="ABCD"
output_filename = os.path.join(directory + dxfmap, output_name + '.' + "dxf")

options = QgsVectorFileWriter.SaveVectorOptions()
options.driverName = "DXF"
options.fileEncoding = "CP1252"
options.onlySelectedFeatures = False
options.destCRS = layer2.crs()
options.layerName = "ABCD Layername"
options.skipAttributeCreation=True
options.setLayerTitleAsName=True

writer = QgsVectorFileWriter.writeAsVectorFormat(
        layer2,
        output_filename,
        options
)

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP