Last active
October 30, 2017 11:28
-
-
Save signedav/f59661504b0f7c35926494d2f0819b45 to your computer and use it in GitHub Desktop.
Action Script for Duplicate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from qgis.PyQt import QtWidgets | |
project = QgsProject.instance() | |
layer = QgsProject.instance().mapLayer('[% @layer_id %]') | |
layer.startEditing() | |
feature_count=0 | |
children_info='' | |
for f in layer.selectedFeatures(): | |
result=QgsVectorLayerUtils.duplicateFeature(layer, f, project, 0 ); | |
feature_count+=1 | |
for ch_layer in result[1].layers(): | |
children_info+='{number_of_children} children on layer {children_layer}\n'.format( number_of_children=str( len( result[1].duplicatedFeatures(ch_layer) ) ), children_layer=ch_layer.name() ) | |
qgis.utils.iface.messageBar().pushMessage( '{number_of_features} features on layer {layer} duplicated with\n{children_info}'.format( number_of_features=str( feature_count ), layer=layer.name(), children_info=children_info ) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment