Not sure if there is a plugin for this but you could run the following code in your Python Console which:
- Creates a new memory layer (you can define the type and crs).
- Iterates through each layer in the ToC and adds the attribute fields.
- Fetches all selected features in each layer and writes it to the memory layer.
- Saves the memory layer as a shapefile (you can define the path). Memory layer is then deleted.
- (Optional) - You can add the saved layer back into QGIS
def run(name):
# To create polygon memory layer, use "Polygon"; "Point" for point layer; "LineString" for line layer
mem_layer = QgsVectorLayer("Polygon?crs=epsg:4326", "Layer_Name", "memory")
mem_layer.startEditing()
for layer in QgsMapLayerRegistry.instance().mapLayers().values():
attr = layer.dataProvider().fields().toList()
mem_layer.dataProvider().addAttributes(attr)
mem_layer.updateFields()
feats = [ feat for feat in layer.selectedFeatures() ]
mem_layer.dataProvider().addFeatures(feats)
mem_layer.commitChanges()
# Change path accordingly
path = r"C:/Users/You/Desktop/Folder/" + name
new_layer = QgsVectorFileWriter.writeAsVectorFormat(mem_layer, path, "utf-8", None, "ESRI Shapefile")
del mem_layer
#QgsMapLayerRegistry.instance().addMapLayer(QgsVectorLayer(path + ".shp", name, "ogr"))
To run the code, type run('Enter_Name')
in the console. "Enter_Name" will be used as the name of the output so you can change this accordingly, keep in mind that you need to include the single quotation marks. If you want to add the output to the ToC, uncomment the last line.
The code also assumes that the attribute fields for your 3 layers are the same, otherwise the attributes of each layer may not be saved in the correct fields.