Set a layer editable through the Python console works fine here (QGIS 2.18.4):
layer=iface.activeLayer()
if not layer.isEditable():
qgis.utils.iface.actionToggleEditing().trigger()
But I do not know how to set a input layer editable in a QGIS processing script:
##Input_layer=vector
# ...
inlayer = processing.getObject(Input_layer)
if not inlayer.isEditable():
#???
Can anybody help me with this?
Answer
You can use QgsVectorLayer.startEditing().
Then once your edits are complete you can either commitChanges() or rollBack() as approriate
##Input_layer=vector
# ...
inlayer = processing.getObject(Input_layer)
if not inlayer.isEditable():
inlayer.startEditing()
# ...
inlayer.commitChanges()
No comments:
Post a Comment