In another thread, I was given this code to import large numbers of dxfs into QGIS. This code works in QGIS2.18, but they just released QGIS 3.0 and have changed the codes to use a different version of Python. This code doesn't work in 3.0. Running it generates a series of requests to set the CRS, but nothing then imports.
How can I edit this code (or other codes) to be compatible with QGIS 3.0? What was changed? I tried an online converter but it didn't alter anything.
import glob, os path = "E:/aawork/aasites/aa-all towns and villages/Hemelhempstead/osmap 2012/" for layer in glob.glob(path + "*.dxf"): vlayer = QgsVectorLayer(layer, 'name', 'ogr') subLayers = vlayer.dataProvider().subLayers() for subLayer in subLayers: geom_type = subLayer.split(':')[-1] if geom_type == 'LineString': uri = "%s|layername=entities|geometrytype=%s" % (layer, geom_type,) dfx_file_name = os.path.splitext(os.path.basename(layer)) layer_name = "%s - %s" % (dfx_file_name,geom_type,) sub_vlayer = QgsVectorLayer(uri, layer_name, 'ogr') QgsMapLayerRegistry.instance().addMapLayer(sub_vlayer)