Skip to content

Instantly share code, notes, and snippets.

@signedav
Last active October 30, 2017 11:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save signedav/f59661504b0f7c35926494d2f0819b45 to your computer and use it in GitHub Desktop.
Save signedav/f59661504b0f7c35926494d2f0819b45 to your computer and use it in GitHub Desktop.
Action Script for Duplicate
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