[Qgis-user] How to define generic VectorFileWriter
Reginald
Reginald.Carlier at ingelmunster.be
Fri Dec 21 06:13:20 PST 2018
Update
#capabilities doesn't mean the editortool is toggled
from qgis.PyQt.QtCore import *
from qgis.core import QgsWkbTypes
perceellayer=None
editlayer=None
layers = [layer for layer in QgsProject.instance().mapLayers().values()]
for lyr in layers:
if lyr.name() == "Parcels":
perceellayer = lyr
if lyr.name() == "layername_of_layer_you_want_to_edit":
editlayer = lyr
if not editlayer.isEditable():
editlayer.startEditing()
percelen = []
features = perceellayer.selectedFeatures()
geom = None
for f in features:
if geom == None:
geom = f.geometry()
else:
geom = geom.combine(f.geometry())
velden = editlayer.fields()
prov = editlayer.dataProvider()
feat = QgsFeature(velden)
feat.setGeometry(geom)
iface.openFeatureForm(editlayer,feat,updateFeatureOnly=True,showModal=False)
(res, outFeats) = editlayer.dataProvider().addFeatures([feat])
print("done")
Regards,
--
Sent from: http://osgeo-org.1560.x6.nabble.com/QGIS-User-f4125267.html
More information about the Qgis-user
mailing list