In QGIS GUI, a line feature is created using this icon
How to create a line with a fixed distance from a vector layer using PyQGIS.
This my example:
from qgis.core import *
from qgis.PyQt.QtCore import QVariant
capa = QgsVectorLayer("Point?crs=epsg:32718", "temp", "memory")
pr = capa.dataProvider()
pr.addAttributes([
QgsField("codigo", QVariant.Int),
QgsField("nombre", QVariant.String)])
capa.updateFields()
...
In Toolbars / mDigitizeToolBar the is action mActionAddFeatures
this create a line feature, i need how to call from Python Console, with parameters.