I found this to list layers: <!-- language: pyqgis --> layers = qgis.core.QgsProject.instance().layerTreeRoot().layerOrder()