Keeping pipes connected after creation

Hi everyone,

I am busy using the “Element.CopyByVector” method to split a length of pipe and place down flanges. It works great, but when the script finishes, the first and last pipe in the run are losing connection to the relevant end connectors like you see below.

I am looking for a way to keep these connected, as the implications of them losing connection means that another system is created.
What I have tried so far is getting the two end connectors of the original pipe, as well as the First connector of the first new pipe, and the last connector of the last pipe and connect those together using the “Connector.ConnectTo” node from MEPover. Unfortunately I have not been successful with this… Can anyone help me? I feel like I am close given that the connections are right next to each other, I just need the right ones I think?
I cannot upload a sample Revit file due to file size, but it is just 4 pipes with the attached Revit Flange family loaded into the routing preference for flanges, with minimum sizes set to allM_Flange - Slip-on - Steel - Class 150.rfa (516 KB) . Any help would be very much appreciated!!
Thank you.
I am using Revit 2019.2 and Dynamo (130.1 KB)

I also have this Python code which I found on the forums,

import clr

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

from Autodesk.Revit.DB import *

import Revit

pipes = UnwrapElement(IN[0])
margin = 0

connectors = {}
connlist =

for pipe in pipes:
conns = pipe.ConnectorManager.Connectors
conns = pipe.MEPModel.ConnectorManager.Connectors
for conn in conns:
if conn.IsConnected:
connectors[conn] = None

for k in connectors.keys():
mindist = 1000000
closest = None
for conn in connlist:
if conn.Owner.Id.Equals(k.Owner.Id):
dist = k.Origin.DistanceTo(conn.Origin)
if dist < mindist:
mindist = dist
closest = conn
if mindist > margin:
connectors[k] = closest
del connectors[closest]

for k, v in connectors.items():

OUT = “Done”

As I understand it this is suppose to find the nearest connector and reconnect items. It works for one pipe, but it does not run on the remainder of them, any ideas?

Thank you

Hi Mitchell,

Maybe this will come in handy, just feed it a bunch of elemens that have a connector on them and it will try to find the closest disconnected connector and try to connect to it.ConnectToClosest.dyn (6.5 KB)


Hi T_Pover,

This seems to be working much better than the previous code… Can’t thank you enough!

1 Like

You are the MEP Dynamo God! This little script will save me so much time. Thank you so much! If you have a github or place you share your scripts I would be very interested to see your other work and anything you have for sale!

For those not using groups to model because of the inherit disconnects that result this script will fix that…and quickly. Setup one group copy around, when our read for flow, ungroup run the script on each area and as long as your pipes are the closest connector you will be fine, you got to watch out for fixtures moving if you are type mapping or what not. If your fixture has an open connector closer than your pipe it will connect to itself and do other weird things. Works great for just copying similar areas as well

1 Like

Thanks for the kind words. I have nothing for sale sadly :wink: My site is really old and I haven’t updated it in years, but there are few workflows for Dynamo that I still use every once in a while.

You’re welcome. Just three nodes vs the spaghetti monster I had created just to start haha.

I remember seeing at one point you worked with Taco…Do they have you developing their BIM things? I know a few guys here in Canada who work with Taco.

I will check out your site! Thanks again


This was next on my list but I have not delved in yet. I wanted to move the tags from on top of each other and other thigns in my model…planned on using bounding boxes if tags even have those. When I get into I will share :wink:

1 Like