Hello, By Using this code from
Civil 3d Help https://help.autodesk.com/view/CIV3D/2022/ENU/?guid=GUID-6A41C6B7-3640-4F47-8125-60117A5DD1DF
[CommandMethod("AddPipe")]
public void AddPipe()
{
CivilDocument doc = CivilApplication.ActiveDocument;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction ts = Application.DocumentManager.MdiActiveDocument.
Database.TransactionManager.StartTransaction())
{
ObjectIdCollection oIdCollection = doc.GetPipeNetworkIds();
// Get the first network in the document
ObjectId objId = oIdCollection[0];
Network oNetwork = ts.GetObject(objId, OpenMode.ForWrite) as Network;
ed.WriteMessage("Pipe Network: {0}\n", oNetwork.Name);
// Go through the list of part types and select the first pipe found
ObjectId pid = oNetwork.PartsListId;
PartsList pl = ts.GetObject(pid, OpenMode.ForWrite) as PartsList;
ObjectId oid = pl["Concrete Pipe"];
PartFamily pfa = ts.GetObject(oid, OpenMode.ForWrite) as PartFamily;
ObjectId psize = pfa[0];
LineSegment3d line = new LineSegment3d(new Point3d(30, 9, 0), new Point3d(33, 7, 0));
ObjectIdCollection col = oNetwork.GetPipeIds();
ObjectId oidNewPipe = ObjectId.Null;
oNetwork.AddLinePipe(oid, psize, line, ref oidNewPipe, false);
Pipe oNewPipe = ts.GetObject(oidNewPipe, OpenMode.ForRead) as Pipe;
ed.WriteMessage("Pipe created: {0}\n", oNewPipe.DisplayName);
ts.Commit();
}
} it tell me Failed to add line pipe alawys How Can I solve this