Hello dsmith:
I am not surprised that you could not Google up anything about the external services. It is not exactly your regular Revit API 1.0.1 feature. It is rather an advanced technique not many user use or even know about, hence the lack of references out there.
However, that is not an excuse for the lack of documentation in our Revit SDK. I have searched and could not find one example or snippet of using MEP servers. The documentation in the RevitAPI.chm file is also less than satisfactory,in my opinion. I have had raised it as I critical issue and assigned it to the responsible MEP team. I will be monitoring their effort and progress, and hopefully we’ll see some concrete improvements soon.
In the meantime, however, I may be of some assistance, or the ADN group if you are a member. I know a big deal about External Services is Revit, and I can tell you all about it. I am not, however, an MEP person, thus I do know nearly nothing about the MEP-related services and how they are supposed to be implemented. At the very least, though, I can point you to the right place so you can at least familiarize yourself with the concept of customizing Revit MEP calculations via external services.
The best place to start is probably the Autodesk.Revit.DB.ExternalService namespace as described in the RevitAPI.chm. It lists all the basic classes (not the derived MEP classes) with decent amount of documentation.
All external services available in Revit are listed it the ExternalServices.BuiltInExternalServices enum.
Out of all those there are five of them related to MEP calculations:
- DuctFittingAndAccessoryPressureDropService
- DuctPressureDropService
- PipeFittingAndAccessoryPressureDropService
- PipePlumbingFixtureFlowService
- PipePressureDropService
User can provide their own external servers for each of the services to use (instead of using the Revit default calculation methods). Such servers implement their respective interfaces of server classes. There are listed here in the same order as above:
- IDuctFittingAndAccessoryPressureDropServer
- IDuctPressureDropServer
- IPipeFittingAndAccessoryPressureDropServer
- IPipePlumbingFixtureFlowServer
- IPipePressureDropServer
To find out more about what each of the servers are expected to do, you need to look those classes up in the CHM file. For example, an implementation of the IDuctPressureDropServer is expected to implement (besides some basic methods) the Calculate method, which Revit will call at times it needs to calculate a pressure drop for a duct.
Once you have your custom server implemented, you need to register it within Revit and then set it as the active server for the particular service. One of such a way is doing it in the OnStartup method as I am going to show here:
public ExternalDBApplicationResult OnStartup(ControlledApplication application)
{
// Get a particular service from Revit
ExternalService service = ExternalServiceRegistry.GetService(ExternalServices.BuiltInExternalServices.IDuctPressureDropServer);
if (service == null)
return Failed;
// Create an instance of your server and register it with the Service.
MyDuctPressureDropCalculator myServer = MyDuctPressureDropCalculator();
service.AddServer(new MyDuctPressureDropCalculator());
// Make Revit to use this server instead of the default one
service.SetActiveServer(myServer.GetServerId())
return Succeeded;
}
There is a lot, lot more, as you will learn when you start using it. The above is just a basic information, but it should get you started, or at least show you what is available.
Thank you
Arnošt Löbel