In this earlier blog post, I demonstrated how to Add / Remove BaseLineRegion in AutoCAD Civil 3D using .NET API. In one of the questions in AutoCAD Civil 3D Customization Forum, I see a developer having an issue in editing the Corridor Baseline Region start and end station. In the Civil 3D API reference document I see the BaselineRegion.StartStation and BaselineRegion.EndStation properties are Get and Set i.e. we can Get the station values as well as we Set them. I thought to give it a try to confirm they are working as per the API reference doc and I do find we can Get as well as Set the station values.
Here is the working C# .NET code snippet :
Corridor corridor = trans.GetObject(corridorId, OpenMode.ForWrite) asCorridor;
// Get the BaselineRegionCollection
BaselineRegionCollection baselineRegionColl = corridor.Baselines[0].BaselineRegions;
// Get the BaselineRegion to update the Start and End Station
BaselineRegion baselineregion = baselineRegionColl["Corridor Region (1)"];
if (baselineregion != null)
{
ed.WriteMessage("\n BaseLineRegion Start Station Before Update : " + baselineregion.StartStation.ToString());
ed.WriteMessage("\n BaseLineRegion End Station Before Update : " + baselineregion.EndStation.ToString());
// update the stations Value
baselineregion.StartStation = 50.00;
baselineregion.EndStation = 568.00;
//rebuild the corridor
corridor.Rebuild();
ed.WriteMessage("\n BaseLineRegion Start Station After Update : " + baselineregion.StartStation.ToString());
ed.WriteMessage("\n BaseLineRegion End Station After Update : " + baselineregion.EndStation.ToString());
}
And the result in AutoCAD Civil 3D 2014 :