Community
Civil 3D Forum
Welcome to Autodesk’s Civil 3D Forums. Share your knowledge, ask questions, and explore popular AutoCAD Civil 3D topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Add Line Pipe

0 REPLIES 0
Reply
Message 1 of 1
abdelftahiti
95 Views, 0 Replies

Add Line Pipe

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

 

Labels (1)
0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Rail Community


 

Autodesk Design & Make Report