Select feature one by one and save it as image

المشرف العام

Administrator
طاقم الإدارة
I have used following code for selecting the features and save it as image.

layer = self.iface.activeLayer(); layer.setSelectedFeatures([]) count =layer.featureCount() lstChalta = [] lstFeatures = processing.features(layer) for elem in lstFeatures: geom = elem.geometry() attr = elem.attributes() layer.setSelectedFeatures([elem.id()]) self.iface.mapCanvas().zoomToSelected( layer ) box = layer.boundingBoxOfSelected() self.iface.mapCanvas().setExtent(box) self.iface.mapCanvas().refresh() self.iface.mapCanvas().refresh() cno= str(attr[layer.fieldNameIndex('cno')]) path = 'D:\Test'+ str(cno) + '.png' self.iface.mapCanvas().saveAsImage(path) #QMessageBox.information(None, "DEBUG:", str(test)) Whenever I run the script, it is selecting only the last feature. However, if I uncomment message box line it is working fine and selecting each and every feature one by one. In addition to that it is saving the image properly.

I want to work the script without showing message.



أكثر...
 
أعلى