We already presented an analysis of the MEP connectors in Revit 2010, but a general introduction to the MEP-specific API is still missing. Or was, until today.
Question: What can I do with the Revit MEP API? What's new in Revit MEP 2010? Are there any additions or enhancements specifically for the MEP flavour? Any new content?
Answer: The Revit 2010 API has been strongly enhanced with new MEP-specific features. The main feature of the RME API is to provide read and write access to the Revit MEP model, including the following HVAC and piping data aspects and main components:
- Traverse ducts, pipes, fittings and connectors in a system.
- Add, remove and modify ducts, pipes and other equipment.
- Read and modify system properties.
- Determine whether a system is well-connected.
- System to manage the top level system properties.
- Ducts and pipes to define the main flow elements.
- Fittings to implement bends and branches in the system.
- Connectors to hook up the ducts, pipes and fittings.
The classes MechanicalSystem and PipingSystem provide the following top-level system functionality:
- Access to equipment, connectors and system type.
- Access to system properties such as flow and static pressure.
- Analysis of system contents: DuctNetwork or PipeNetwork.
The elements contained within a system are not automatically returned in the flow direction, and the TraverseSystem SDK sample demonstrates how to implement traversal in direction of flow for a given system.
The ducts and pipes are represented by the classes Duct, FlexDuct, Pipe and FlexPipe. They provide the following functionality:
- Read access to duct properties, types, and geometry.
- Change duct or pipe type.
- Move or layout duct or pipe.
The layout functionality can be driven by two points, one point and a connector, or two connectors.
The fittings are represented by family instances, which are created with dedicated Autodesk.Revit.Creation.Document methods New*Fitting, where * can be replaced by any one of Elbow, Tee, Cross, Takeoff, Transition, UnionFitting. The fitting properties can be accessed through the FamilyInstance.MEPModel property.
The MEP connectors are represented by different classes depending on the context. This caused some confusion, which is why this topic has already been discussed in a previous post. In a family document, during the connector definition, we use the specialised classes DuctConnector, PipeConnector and ElectricalConnector. In the project document, the connectors are represented using the Connector class. The connector features include:
- Read duct, pipe, and fitting connector properties such as Flow, Coefficient, Demand.
- Access physical connector properties e.g. Origin, Angle, Height, Width, Radius.
- The family connectors define Flow, Flow Configuration, Coefficients, Loss Method.
- Change connector size and location.
- Connect and disconnect.
For the element creation within a project environment, we have several new methods on the creation document:
- New*System to create a new mechanical or piping system.
- NewDuct, NewFlexDuct, NewPipe and NewFlexPipe to create new elements.
- New*Fitting to create new fittings, with * being one of Cross, Elbow, TakeOff, TeeFitting, Transition, Union.
To create the connector definitions within the family context, the FamilyItemFactory class accessed through the Document.FamilyCreate property provides the following new methods:
The Revit SDK includes the following new MEP-specific sample applications to demonstrate the use of the new functionality:
- AutoRoute: Route a set of ducts and fittings between a base air supply equipment and two terminals.
- AvoidObstruction: Detect and resolve obstructions between ducts, pipes, and beams
- TraverseSystem: Traverse a well-connected mechanical or piping system in the direction of flow
- CreateAirHandler: Create an air handler and add connectors
The first three demonstrate new RME API features, the fourth is an MEP-specific family API sample.
These samples were also presented in the recent Revit programming webcast.
The MEP contents have also been extended. One important new product feature is the interoperability with Inventor to support the MEP workflow.
Here is a vaguely related question on application compatibility between different flavours of Revit and between the 32 and 64 bit platforms:
Question: Will a Revit plug-in assembly created with the 32-bit Revit MEP 2010 API work on 32-bit Revit Architecture 2010 and in 64-bit Revit MEP or Architecture 2010?
Answer: If the plug-in makes use of MEP-specific functionality through the Revit API in some of its commands, then those commands will only work on Revit MEP. You can query what flavour of Revit your plug-in is currently running on and enable or disable certain functionality accordingly. The vast majority of the Revit API will work unchanged on all flavours.
Because the .NET framework creates assemblies that are not bound to a specific architecture, your application created in a 32-bit environment should also work unmodified in a 64-bit one. You need to test this, though, to ensure that you have not inadvertently bound it to 32 bits in some way.