QGIS is such an amazing tool with lots of useful features, so that it's easy to overlook some of them.
Just to be sure it's not already implemented in QGIS 2.18:
Is there any Attribute Table option to run a layer Action on all currently selected features?
I'm using a Processing script as workaround, but it would be nice to have this feature directly implemented in the Attribute Table.
##MyTools=group
##VectorLayer=vector
##action_name=string
from qgis.core import *
import qgis.utils
from qgis.gui import *
layer = processing.getObject(VectorLayer)
actionManager = layer.actions()
actions = actionManager.listActions()
if len(actions) > 0:
cont = False
i = -1
for a in actions:
i = i+1
if a.name() == action_name:
cont = True
break
if cont:
selFeatures = layer.selectedFeatures()
if len(selFeatures) > 0:
for feature in selFeatures:
actionManager.doActionFeature(0,feature)
else:
qgis.utils.iface.messageBar().pushMessage("Processing Error"," No features selected.",level= QgsMessageBar.WARNING,duration=5)
else:
qgis.utils.iface.messageBar().pushMessage("Processing Error"," Wrong layer action defined.",level= QgsMessageBar.WARNING,duration=5)
else:
qgis.utils.iface.messageBar().pushMessage("Processing Error"," No layer action found.",level= QgsMessageBar.WARNING,duration=5)
No comments:
Post a Comment