In AutoCAD Civil 3D we can conveniently add labels to Pipe / PipeNetwork using UI tools / commands as shown in the screenshot below :
If you want to add Labels to Civil 3D Pipe objects without any user interaction, you can use PipeLabel.Create() .NET API.
Here is a C# .NET code snippet demonstrating the how to add a Pipe Label :
ObjectId pipeID = ed.GetEntity(opt).ObjectId;
CivilDocument civildoc = CivilApplication.ActiveDocument;
using (Transaction ts = AcadApp.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction())
{
// We will use PipeLabel.Create()
// public static ObjectId Create( ObjectId pipeId, double ratio, ObjectId labelStyleId )
// pipeId - Type: ObjectId // The ObjectId of Pipe on which the label is located.
// ratio - Type: System.Double // The relative position of the label to the pipe.
// labelStyleId - Type: ObjectId // The ObjectId of a PipeLabel style to use.
ObjectId labelStyleId = civildoc.Styles.LabelStyles.PipeLabelStyles.PlanProfileLabelStyles[0];
PipeLabel.Create(pipeID, 0.5, labelStyleId);
ts.Commit();
}
And the result in Civil 3D :