edit - This code no longer works in the new version of QGIS (QGIS 3.0) If I paste it into the python console it generates a series of requests for the CRS but then imports nothing. QGIS 3.0 has moved to a newer version of Python and the code I have is incompatible.
How do I edit it to make it work again?
I just merged several hundred layers into QGIS which had been imported using this code:-
import glob, os path = "H:/aOsmap/Miltkeyn/2012 ntfs/all/" 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] 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)
Merging them was difficult because the merge window (vector-merge layers) mixes up the linestring layers and the point layers so selecting just the point layers or just the linestring layers, from about over 600 layers, is laborious and prone to clicking on the wrong layer.
It would be easier and quicker to import all the points from my dxfs in one go and merge those (saving the merged file) and then import all the linestrings from the dxfs and merge those.
However, I don't understand the code so I have no idea what to alter to just select points or just select lines.
Can anyone help me?