This VB.NET code snippet demonstrates how to add a Civil 3D SampleLine using COM API IAeccSampleLines:: AddByPolyline() method and then check whether the sample line is locked to the station using IAeccSampleLine:: LockToStation, before updating it's Station value using COM API IAeccSampleLine:: Station Property.
'idEnt is Polyline ObjectId
Dim pLineEntity As Autodesk.AutoCAD.DatabaseServices.Entity = _
DirectCast(trans.GetObject(idEnt, OpenMode.ForWrite), Autodesk.AutoCAD.DatabaseServices.Entity)
'idEnt1 is Alignment ObjectId
Dim alignmentEntity As Autodesk.AutoCAD.DatabaseServices.Entity = _
DirectCast(trans.GetObject(idEnt1, OpenMode.ForWrite), Autodesk.AutoCAD.DatabaseServices.Entity)
Dim pline As Autodesk.AutoCAD.Interop.Common.AcadLWPolyline = _
DirectCast(pLineEntity.AcadObject, Autodesk.AutoCAD.Interop.Common.AcadLWPolyline)
Dim oAlignment As Autodesk.AECC.Interop.Land.AeccAlignment = _
DirectCast(alignmentEntity.AcadObject, Autodesk.AECC.Interop.Land.AeccAlignment)
Dim oSampleLine As Autodesk.AECC.Interop.Land.AeccSampleLine = _
oAlignment.SampleLineGroups.Item(0).SampleLines.AddByPolyline("My_SampleLine", pline, False)
'' IAeccSampleLine:: Station Property
'' Gets or sets the alignment station for this sample line.
ed.WriteMessage(vbCrLf + "Station Value :" + oSampleLine.Station.ToString())
' Check whether the sample line is locked to the station
If(oSampleLine.LockToStation)
oSampleLine.LockToStation = False
End If
'' Now Change the Station Value
'' Following hardcoded value is applicable to Civil 3D Sample DWG - "Sections-Views-Create.dwg"
oSampleLine.Station = 550.50
ed.WriteMessage(vbCrLf + "Station Value After Change:" + oSampleLine.Station.ToString())
trans.Commit()
Here is the Result :
Hope this is useful to you!