[Qgis-developer] Layer selection
Benoît Laurent
blaurent at heurisis.eu
Tue Oct 1 01:20:17 PDT 2013
Hello,
I do not know if this is the right place to ask this question. If not,
please tell me.
I would like to iterate over a list of layers. For each layer, I would
like to zoom to its extent and create a pdf file (using the QgsComposer).
At the beginning, the layers are already loaded but not selected. I am
facing a problem to select each layer. The following code does not work.
The list of selected layers is desperately empty.
from qgis.core import (QgsMapLayer,
QGis)
def run_script(iface):
legend = iface.legendInterface()
layers = iface.mapCanvas().layers()
if len(layers) > 0:
l = layers[0]
legend.setLayerVisible(l, True)
iface.setActiveLayer(l)
print legend.selectedLayers()
I am stuck. Any help would be appreciated.
Regards,
Benoît
More information about the Qgis-developer
mailing list