<div dir="ltr">Hi,<div><br></div><div>I'm working with a lot of layers and need to copy/paste features with attributes from source layers to destination layers, within a rectangle.</div><div><br></div><div>I'm using the "multiple selection by rectangle" plugin by Felipe Ferrari and Luiz Andrade to make a selection on all my layers and looked for a script but do not find something simple and easy.</div><div><br></div><div>So I've rapidly coded this :</div><div>---</div><div>def selectedFeaturesCopy(sourceLayerName, destLayerName):<br><br>    sourceLYR = QgsProject.instance().mapLayersByName(sourceLayerName)[0]<br>    destLYR = QgsProject.instance().mapLayersByName(destLayerName)[0]<br>    destLYR.startEditing()<br>    data_provider = destLYR.dataProvider()<br>    data_provider.addFeatures(sourceLYR.getSelectedFeatures())<br>    destLYR.commitChanges()<br>    <br>selectedFeaturesCopy('source layer', 'destination layer')<br></div><div>---</div><div>Badly, I see that, as I rode elsewhere, it only copies geometry, not attributes. I'll have to parse every feature to add the attributes.</div><div></div><div><br></div><div>So far I understand that features are only geometries. Why is it called features then ?</div><div></div><div><br></div><div>More than that, when I look at the QGIS code, I see that some functions dedicated to features do work with attributes too ?! Isn't it inconsistent ?</div><div><br></div><div>Wouldn't it be more efficient that some methods, like addFeature(), have at least a flag to add attributes too ? In the addFeature() code (<a href="https://qgis.org/api/qgsvectorlayer_8cpp_source.html#l00993">https://qgis.org/api/qgsvectorlayer_8cpp_source.html#l00993</a>), the flag seems unused.</div><div> <br></div><div>Regards,</div><div><br></div><div>Jésahel</div></div>