Creates a new MEP mechanical system element.
Namespace: Autodesk.Revit.CreationAssembly: RevitAPI (in RevitAPI.dll) Version: 21.0.0.0 (21.1.1.109)
Syntax
Parameters
- baseEquipmentConnector
- Type: Autodesk.Revit.DB..::..Connector
One connector within base equipment which is used to connect with the system.
The base equipment is optional for the system, so this argument may be nullNothingnullptra null reference (Nothing in Visual Basic).
The baseEquipmentConnector should not be included in the connectors.
- connectors
- Type: Autodesk.Revit.DB..::..ConnectorSet
Connectors that will connect to the system.
The owner elements of these connectors will be added into system as its elements.
- ductSystemType
- Type: Autodesk.Revit.DB.Mechanical..::..DuctSystemType
The system type.
Return Value
If creation was successful then an instance of mechanical system is returned,
otherwise an exception with information will be thrown.
Remarks
Examples
CopyC#
ConnectorSet connectorSet = new ConnectorSet();
Connector baseConnector = null;
ConnectorSetIterator csi = null;
ICollection<ElementId> selectedIds = uiDocument.Selection.GetElementIds();
Document document = uiDocument.Document;
foreach (ElementId id in selectedIds)
{
Element e = document.GetElement(id);
if (e is FamilyInstance)
{
FamilyInstance fi = e as FamilyInstance;
Family family = fi.Symbol.Family;
if (family.FamilyCategory.Name == "Mechanical Equipment")
{
if (null != fi.MEPModel)
{
csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator();
while (csi.MoveNext())
{
Connector conn = csi.Current as Connector;
if (conn.Direction == FlowDirectionType.Out && conn.DuctSystemType == DuctSystemType.SupplyAir)
{
baseConnector = conn;
break;
}
}
}
}
else if (family.FamilyCategory.Name == "Air Terminals")
{
csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator();
csi.MoveNext();
connectorSet.Insert(csi.Current as Connector);
}
}
}
MechanicalSystem mechanicalSys = null;
if (null != baseConnector && connectorSet.Size > 0)
{
mechanicalSys = uiDocument.Document.Create.NewMechanicalSystem(baseConnector, connectorSet, DuctSystemType.SupplyAir);
}
CopyVB.NET
Dim connectorSet As New ConnectorSet()
Dim baseConnector As Connector = Nothing
Dim csi As ConnectorSetIterator = Nothing
Dim selectedIds As ICollection(Of ElementId) = uiDocument.Selection.GetElementIds()
Dim document As Document = uiDocument.Document
For Each id As ElementId In selectedIds
Dim e As Element = document.GetElement(id)
If TypeOf e Is FamilyInstance Then
Dim fi As FamilyInstance = TryCast(e, FamilyInstance)
Dim family As Family = fi.Symbol.Family
If family.FamilyCategory.Name = "Mechanical Equipment" Then
If fi.MEPModel IsNot Nothing Then
csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator()
While csi.MoveNext()
Dim conn As Connector = TryCast(csi.Current, Connector)
If conn.Direction = FlowDirectionType.Out AndAlso conn.DuctSystemType = DuctSystemType.SupplyAir Then
baseConnector = conn
Exit While
End If
End While
End If
ElseIf family.FamilyCategory.Name = "Air Terminals" Then
csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator()
csi.MoveNext()
connectorSet.Insert(TryCast(csi.Current, Connector))
End If
End If
Next
Dim mechanicalSys As MechanicalSystem = Nothing
If baseConnector IsNot Nothing AndAlso connectorSet.Size > 0 Then
mechanicalSys = uiDocument.Document.Create.NewMechanicalSystem(baseConnector, connectorSet, DuctSystemType.SupplyAir)
End If
Exceptions
See Also