Insert connectors

Greetings, everyone!
I have a simple question, but it’s one that’s kept me busy all day with a project issue. Is it possible to insert hydraulic connectors at specific points automatically using Dynamo? Or is it a 100% manual process?

Assuming you’re wanting to create them in a family, yes, it’s available within the API.
CreatePipeConnector Method

1 Like

Genius Loci have some few nodes there maybe could help

1 Like

I’m trying to install it on a gutter outlet in my project. I’m selecting it within the model. I created the code below, but it gives an error saying it can’t find the piping system within the project, which is very strange, since I have pipes with this configuration.

# Import necessary libraries for Revit API and Dynamo
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Plumbing import PipeSystemType

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

# Get the current Revit document
doc = DocumentManager.Instance.CurrentDBDocument

# Dynamo node inputs
# IN[0] = The list of Faces where the connectors will be created
# IN[1] = The desired RADIUS for the connector in CENTIMETERS (e.g., 5)
# IN[2] = The NAME of the Pipe System (text) OR the System Type element itself

# Try to "unwrap" the Dynamo elements to use them in the Revit API
try:
    faces = UnwrapElement(IN[0])
except:
    faces = IN[0]
    
radius_in_cm = IN[1]
systemTypeInput = IN[2]

# Block to ensure the system name is always a text string
systemTypeName = ""
if isinstance(systemTypeInput, str):
    systemTypeName = systemTypeInput
else:
    try:
        systemTypeName = Element.Name.GetValue(systemTypeInput)
    except:
        systemTypeName = "INVALID INPUT"

# List to store the created connectors
new_connectors = []

# Robust method to find the Pipe System Type
# This block does NOT use the problematic '.OfClass(PipeSystemType)'
collector = FilteredElementCollector(doc).WhereElementIsElementType()
all_element_types = collector.ToElements()
pipeSystemType = None

for el_type in all_element_types:
    if isinstance(el_type, PipeSystemType) and Element.Name.GetValue(el_type) == systemTypeName:
        pipeSystemType = el_type
        break

# Check if the system type was found
if pipeSystemType is None:
    OUT = "ERROR: Pipe System Type '" + systemTypeName + "' not found in the project."
else:
    # Start a transaction
    TransactionManager.Instance.EnsureInTransaction(doc)

    # Convert the radius to Revit's internal units
    internal_radius = UnitUtils.ConvertToInternalUnits(radius_in_cm, UnitTypeId.Centimeters)
    
    # Loop through each face
    for face in faces:
        try:
            # Use the modern and correct method to create the connector
            connElement = ConnectorElement.CreatePipeConnector(doc, pipeSystemType, face.Reference)
            
            # Set the properties using BuiltInParameters
            paramRadius = connElement.get_Parameter(BuiltInParameter.CONNECTOR_RADIUS)
            paramRadius.Set(internal_radius)
            
            paramFlowDir = connElement.get_Parameter(BuiltInParameter.RBS_PIPE_FLOW_DIRECTION_PARAM)
            paramFlowDir.Set(2) # 2 means "Out"
            
            new_connectors.append(connElement)
        except Exception as e:
            new_connectors.append("Error creating connector: " + str(e))

    # Finalize the transaction
    TransactionManager.Instance.TransactionTaskDone()

    OUT = new_connectors

It may seem strange, but when I use the “create pipe connector” node, my dynamo freezes and doesn’t generate what I expected. Can you see if it works normally for you, please?

could you show your graph ?

1 Like

Before that, I’m just selecting the gutters and processing them to get the gutter outlet. With that, I select the bottom faces, where the connectors should be positioned.

you will need the reference from surface and as autodesk db surface, genius loci should have some nodes for that as well

1 Like

I believed that the surfaces to faces node would be able to do this job. So do I need another node besides it?

1 Like

yes and keep in mind will only work on planar surfaces, and in family document

1 Like

So in this case, is it unfeasible to apply this node to a house project, for example?


and be families there can host connector

1 Like

So that’s the problem, I’m trying to put it in a family within my project.

yes, but guess its possible as well, with some background open, but another topic

1 Like

I will try to research it! Thank you very much!

1 Like

genius loci have some great nodes for that as well… :wink:

1 Like

to be able to access and edit the family through dynamo?

yes :wink: and in project document as well, play around with it, we have a tons of that kind here in the forum, just search, and if it cant work, just show us where and we will be happy to help :wink:

1 Like

Right! Thank you so much again, this was a great help!

1 Like