Create Line, Two Point

I have a question that I am doing wrong in the python code to be able to create a line, I know there are nodes for this I am just trying to understand a little python and I would like to know what the error is

# Load the Python Standard and DesignScript Libraries
import sys
import clr

# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *


# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

def create_line(start_point, end_point):
    civil_doc = CivilApplication.ActiveDocument
    with civil_doc.LockDocument():
        with civil_doc.StartTransaction():
            ms = civil_doc.GetDocument().Database.ModelSpace
            start = AeccPoint3d(start_point.X, start_point.Y, start_point.Z)
            end = AeccPoint3d(end_point.X, end_point.Y, end_point.Z)
            line = AeccLine(start, end)
            ms.AppendEntity(line)
            civil_doc.GetDocument().TransactionManager.QueueForGraphicsFlush()
    
    return line

# Puntos de inicio y fin de la línea
start_point = Point.ByCoordinates(0, 0, 0)
end_point = Point.ByCoordinates(10, 10, 0)

# Crear la línea en Civil 3D
created_line = create_line(start_point, end_point)

# Salida de la línea creada
OUT = created_line

@Christhian ,

you need transactions! and the right syntex look at this…

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#Preparing input from dynamo to revit
element = UnwrapElement(IN[0])

#Do some action in a Transaction
TransactionManager.Instance.EnsureInTransaction(doc)
#create something!
TransactionManager.Instance.TransactionTaskDone()

OUT = element

KR

Andreas

Hello, thank you very much for your answer, but I am trying to do it in civil 3d

Hi @Christhian
Can you look at this