0

Within the QGIS python console, I'm trying to convert a dxf file into a shp file. I run this section of code, and am not getting an error but no output file is generated. Wondering if I'm missing something in here.

import sys
from osgeo import ogr
import re
from os import path

#http://www.agt.bme.hu/gis/gdal/dxf2shp.py
# for QGIS script runner
def run_script(iface):
    dxf_name = "C:/Users/dxf_file.dxf"
    target_name = "C:/Users/shape_file.shp"
    # enter geometry type ogr.wkbPoint | ogr.wkbLineString | ogr.wkbPolygon
    shp_type = ogr.wkbLineString
    # enter regexp to filter layers
    dxf_layer_filter = '.*'
    res = convert(dxf_name, target_name, shp_type, dxf_layer_filter)
    if res == 0:
        (shpdir, shpfile) = path.split(target_name)# load the shape
        iface.addVectorLayer(target_name, shpfile, 'ogr')
2

0

Your Answer

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

Browse other questions tagged or ask your own question.