Document.NewMechanicalSystem
Method
Description:
Creates a new MEP mechanical system element.
Creates a new MEP mechanical system element.
Remarks:
This method will regenerate the document even in manual regeneration mode.
This method will regenerate the document even in manual regeneration mode.
Syntax
public MechanicalSystem NewMechanicalSystem(
Connector baseEquipmentConnector,
ConnectorSet connectors,
DuctSystemType ductSystemType
)
Examples
// create a connector set for new mechanical system
ConnectorSet connectorSet = new ConnectorSet();
// Base equipment connector
Connector baseConnector = null;
// Select a Parallel Fan Powered VAV and some Supply Diffusers
// prior to running this example
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;
// Assume the selected Mechanical Equipment is the base equipment for new system
if (family.FamilyCategory.Name == "Mechanical Equipment")
{
//Find the "Out" and "SupplyAir" connector on the base 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")
{
// add selected Air Terminals to connector set for new mechanical system
csi = fi.MEPModel.ConnectorManager.Connectors.ForwardIterator();
csi.MoveNext();
connectorSet.Insert(csi.Current as Connector);
}
}
}
MechanicalSystem mechanicalSys = null;
if (null != baseConnector && connectorSet.Size > 0)
{
// create a new SupplyAir mechanical system
mechanicalSys = uiDocument.Document.Create.NewMechanicalSystem(baseConnector, connectorSet, DuctSystemType.SupplyAir);
}
Parameters
Parameter | Type | Description |
---|---|---|
baseEquipmentConnector | 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 <span class="keyword"><span data-languagespecifictext="cpp=nullptr|vb=Nothing|nu=null" id="LST72E0836B_1"></span></span>. The baseEquipmentConnector should not be included in the connectors. |
connectors | ConnectorSet | Connectors that will connect to the system. The owner elements of these connectors will be added into system as its elements. |
ductSystemType | DuctSystemType | The system type. |
Return Value
Type | Description |
---|---|
MechanicalSystem | If creation was successful then an instance of mechanical system is returned, otherwise an exception with information will be thrown. |
Exceptions
Exception | Condition |
---|---|
InvalidOperationException | Thrown when calling this function outside of the Autodesk Revit MEP product. |
ArgumentNullException | Thrown when the input connectors parameter value is. |
ArgumentOutOfRangeException | Thrown when the ductSystemType parameter is out of permitted scope. |
ArgumentException | Thrown when some connectors can't be used to create the mechanical system. All the input connectors and base equipment connector should match system type and domain with the system, and they should not have been used in another system. The owner of BaseConnector should be a mechanical equipment, and the owner of other connectors should be a mechanical equipment or air terminal. |
InvalidOperationException | Thrown when the mechanical system creation failed. |