Setting Instance of MULTIPLE LAYERS using "mapLayersByName" in QGIS Python Scripting?

المشرف العام

Administrator
طاقم الإدارة
Setting Instance of MULTIPLE LAYERS using "mapLayersByName" in QGIS Python Scripting?

I'm currently using "mapLayersByName" successfully to set one active layer at a time as follows...

vl = QgsMapLayerRegistry.instance().mapLayersByName('My_Layer')[0]iface.setActiveLayer(vl)Can an instance of multiple layers be set using the "mapLayersByName" method?

I have tried...

vl = QgsMapLayerRegistry.instance().mapLayersByName('My_First_Layer', 'My_Second_Layer')[0]iface.setActiveLayer(vl)As you can see my end goal in this case would be to set the layers within that instance of MULTIPLE layers (vl) as the active layers using the "iface.setActiveLayer()" method. I notice this method is not plural (i.e. not "setActiveLayers()"). Significant?



أكثر...
 
أعلى