Resolve disconnects when sprinkler family is replaced

Hi, so what I have here is a set of sprinklers that were modelled in the wrong Family Category “Pipe Accessories” instead of “Sprinklers”. So now, when I edit the Family category and replace it in my project, all my sprinklers get disconnected. I’m trying to attach them back into the system by using MEPover nodes.

Here’s my script and image for reference: Add Sprinkers to System.dyn (19.7 KB)

Currently, my sprinklers look like this:

When I run my script, I get null in my Element.ConnectInto node. I believe that is because the end of the pipe is still being considered as connected?

Now if I manually go to a pipe and slightly drag the end up a bit as shown:

It now shows the pipe end disconnected as well and then when I run the same script above, it works exactly as intended, ie it connects the pipe and sprinkler.

My question is, is there any way to get this done automatically through the script itself? I need to do this for hundreds of sprinklers.

Try moving the sprinklers a small distance before you connect them.

find the sprinkler connector location and make sure it matches the pipe end connector.