Reconnect Gravity Pipes to Structures in Civil 3D (Dynamo or API Solution?)

Reconnect Gravity Pipes to Structures in Civil 3D (Dynamo or API Solution?)

i_syed7CYDV
Enthusiast Enthusiast
721 Views
6 Replies
Message 1 of 7

Reconnect Gravity Pipes to Structures in Civil 3D (Dynamo or API Solution?)

i_syed7CYDV
Enthusiast
Enthusiast

 

Hello, everyone.

 

I am working on a Gravity Pipe Network (storm/sewer) in Civil 3D, and I have multiple locations where pipes are visually touching the manholes but are logically disconnected (Start/End Structure not assigned).

Since this issue exists in many locations, I would like to know:

Is there a way to reconnect all pipes to the nearest structures in one batch using:

  • Dynamo for Civil 3D, or
  • Civil 3D API / .NET plugin, or
  • any built-in command?

The pipe endpoints are already very close to the structures (within a small tolerance).

I am looking for a one-time automated solution instead of manually assigning start/end structures.

Any guidance or recommended workflow would be appreciated

I attached the drawing and highlighted those locations with circles

 
 

 

 

 

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

 

 
 

 

 

 

 

0 Likes
722 Views
6 Replies
Replies (6)
Message 2 of 7

i_syed7CYDV
Enthusiast
Enthusiast

Any update please 

0 Likes
Message 3 of 7

Jeff_M
Consultant
Consultant

@i_syed7CYDV The .NET API has the Structure.ConnectToPipe Method which could be used to accomplish this task. I would loop through the Network's structures and pipes looking for those that are within a specific tolerance then connect if close.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 4 of 7

i_syed7CYDV
Enthusiast
Enthusiast

@Jeff_M 

Thank you for the suggestion.
Would it be possible to share a simple sample code using Structure.ConnectToPipe with a tolerance check?
It would really help.

 

0 Likes
Message 5 of 7

i_syed7CYDV
Enthusiast
Enthusiast

Any update please.

0 Likes
Message 6 of 7

Jeff_M
Consultant
Consultant

@i_syed7CYDV I suggested what you can do, have you tried to create your own code using my suggestion? I had hand surgery and have no plans to do any code writing for sometime.

Jeff_M, also a frequent Swamper
EESignature
0 Likes
Message 7 of 7

BlackBox_
Advisor
Advisor

@i_syed7CYDV - give this a try, so my partner @Jeff_M can heal: 

 

                using (Transaction tr = db.TransactionManager.StartTransaction())
                {
                    Structure structure = (Structure)tr.GetObject(strId, OpenMode.ForWrite);

                    foreach (ObjectId ssId in ssIds)
                    {
                        Pipe pipe = (Pipe)tr.GetObject(ssId, OpenMode.ForRead);
                        
                        if (pipe.ConnectedPartCount == 2)
                        {
                            ed.WriteMessage($"\nPipe \"{pipe.Name}\" is already connected at both ends, skipping.");
                            continue;
                        }

                        if (pipe.StartStructureId == strId || pipe.EndStructureId == strId)
                        {
                            ed.WriteMessage($"\n** Pipe \"{pipe.Name}\" is already connected to structure \"{structure.Name}\". ** ");
                            continue;
                        }

                        try
                        {
                            pipe.UpgradeOpen();
                            bool ok = true;

                            if (pipe.StartStructureId == ObjectId.Null)
                            {
                                ok = false;
                                structure.ConnectToPipe(pipe.ObjectId, ConnectorPositionType.Start);
                            }
                            
                            if (ok)
                                structure.ConnectToPipe(pipe.ObjectId, ConnectorPositionType.End);

                            ed.WriteMessage($"\nConnected pipe \"{pipe.Name}\" to structure \"{structure.Name}\".");
                        }
                        catch (System.Exception ex)
                        {
                            ed.WriteMessage($"\n** Failed to connect pipe \"{pipe.Name}\" to structure \"{structure.Name}\": {ex.Message} **");
                        }
                    }

                    tr.Commit();
                }

 

 


"How we think determines what we do, and what we do determines what we get."

Chris (BlackBox) Bradley
Managing Partner / Developer / Civil Designer
Quux Software | Sincpac C3D | Style Explorer

0 Likes