In AutoCAD Civil 3D, programmatically we can create Offset Alignment using overloaded Alignment.CreateOffsetAlignment() API. Once we have created an Offset Alignment, we can call OffsetAlignmentInfo.AddWidening() to create a road widening for a specific section of the road.
Here is a C# .NET code snippet demonstrating usage of OffsetAlignmentInfo.AddWidening() API :
using (Transaction trans = db.TransactionManager.StartTransaction())
{
ObjectIdCollection alignmentIdColl = civilDoc.GetAlignmentIds();
foreach (ObjectId alignmentId in alignmentIdColl)
{
alignment = alignmentId.GetObject(OpenMode.ForRead) asAlignment;
if (alignment.Name.ToString() == "Centerline (1)")
break;
}
if (alignment != null)
{
// Get a AlignmentStyle Object to use in OffSet Alignment creation
ObjectId offsetAlignmentStyleId = civilDoc.Styles.AlignmentStyles["Design Style"];
if (offsetAlignmentStyleId == null)
{
ed.WriteMessage("\nOffset Alignment Style NOT found !");
return;
}
// Now create the OffSetAlignment
// A negative value (offset < 0) indicates the Offset Alignment is at the left of the parent alignment.
// A positive value (offset > 0) indicates the Offset Alignment is at the right.
ObjectId offsetAlignmentId = Alignment.CreateOffsetAlignment("Offset_Alignment", alignment.ObjectId, -30.00, offsetAlignmentStyleId);
// Open the Offset Alignment object to add road widening
Alignment offsetAlignment = offsetAlignmentId.GetObject(OpenMode.ForWrite) asAlignment;
OffsetAlignmentInfo offsetInfo1 = offsetAlignment.OffsetAlignmentInfo;
// Now use AddWidening( double startStation, double endStation, double offsetDistance )
// This method will create a specific region from startStation to endStation
// with slim entry transition and exit transition.
offsetInfo1.AddWidening(200.00, 533.0, 40.0);
}
trans.Commit();
}
Following picture shows how it appears in AutoCAD Civil 3D :
Hope this is useful to you!