title: Zoom to a specific pyqgis layer
body: <p>I am trying to zoom in a specific layer but I have not succeeded. He tried several answers but it doesn't work for me. </p>
  
  <p>This is my code</p>
  
  <pre><code>from qgis.utils import *
  from qgis.PyQt.QtCore import *
  from qgis.PyQt import QtGui
  import os
  
  fn8=rutas[2]
  fn8=fn8.rstrip()
  fn8=fn8+"\Datos Puntos Qgis.shp"
  fn8=fn8.rstrip()
  layer6 = QgsVectorLayer(fn8, 'ObrasCiviles', 'ogr')
  QgsProject.instance().addMapLayer(layer6) # Lo añado al mapa de capas
  
  
  QgsProject.instance().layerTreeRoot().findLayer(layer6.id()).setExpanded(False)
  
  layer6 = iface.activeLayer ()
  canvas = iface.mapCanvas ()
  canvas = qgis.utils.iface.mapCanvas ()
  canvas.zoomToSelected (layer6)
  canvas.refresh ()
  </code></pre>
  
  <p>Either it gives me a mistake or it does nothing to me</p>