Several Revit API classes work together to provide the ability to add fabrication components to a Revit document.
Before you can place fabrication parts in an MEP model, you must specify a fabrication configuration and load fabrication services into the model. There are a number of classes in the Revit API to facilitate this process including:
The primary classes involved in MEP Fabrication are covered in more detail below. Sample code can be found in the Revit SDK in the FabricationPartLayout sample.
Using the FabricationConfiguration class, users can get and set the fabrication configuration settings for the document. They can also load and unload services, reload the fabrication configuration, get loaded services, get fabrication specifications, get material and insulation information from the configuration, and get connector information.
There is only one fabrication configuration for the document and you can get it using the static FabricationConfiguration.GetFabricationConfiguration() method. To change the configuration, call the overloaded SetConfiguration() method, passing in a FabricationConfigurationInfo object which contains the information about the FabricationConfiguration. One overload of the SetConfiguration() method will set the configuration with the global profile, and one takes a profile name and sets the configuration with that specific profile. (The FabricationConfiguration.GetProfile() method and the FabricationConfigurationInfo.GetProfiles() method return the profile associated with the loaded configuration or all configurations, respectively.)
The ReloadConfiguration() method reloads the fabrication configuration from its source fabrication configuration. This must be done prior to loading fabrication services.
Use the GetAllLoadedServices() method to get all loaded services or GetAllUsedServices() to get only used fabrication services. A service is in use if any fabrication part in the service is created by the user. Both methods return a list of FabricationService objects.
LoadServices() and UnloadServices() can be used to load and unload a list of fabrication services, respectively.
The FabricationConfiguration class also has methods to get configuration data abbreviations. The GetMaterialAbbreviation() returns the abbreviation of the material or the insulation or the double wall material. GetSpecificationAbbreviation() returns the specification abbreviation for the given specification and GetInsulationSpecificationAbbreviation() will return the abbreviation for the given insulation specification.
Fabrication services are part of the fabrication configuration and define what fabrication service buttons can be used. The GroupCount property returns the number of groups in the service. Using the index of the groups, you can call GetGroupName() to get the name of the group. The method GetButtonCount() will return the number of buttons in a specified group and the actual buttons can be retrieved by calling GetButton() with a specified group index and button index.
The FabricationServiceButton class contains information about a fabrication button. A fabrication service button defines an item that can be used to define a FabricationPart, possibly subject to a list of specific conditions. Fabrication service buttons are part of a fabrication service.
Using the FabricationPart class, users can create, place, move and align fabrication parts in a Revit model. Users can also get or set the dimensions of the fabrication part, and get the fabrication hosted information and rod information.
The overloaded static FabricationPart.Create() method creates a new fabrication part based on a fabrication service button. The overloaded static CreateHanger() method creates a hanger on another fabrication part. The static AlignPartByConnectors() method will move and align a fabrication part by one of its connectors to align with another connector.
FabricationParts can also be created from design elements using the DesignToFabricationConverter class. The Convert() method will convert a set of MEP design elements into fabrication parts. Successfully created FabricationParts can be obtained using the GetConvertedFabricationParts() methods. If the Convert() method indicates a partial failure, the GetPartialConvertFailureResults() method will return a list of possible failures. For partial failure types (e.g. InvalidConnections) there is a corresponding method of the DesignToFabricationConverter class to retrieve a list of the ElementIds of the FabricationParts with that error type (e.g. GetConvertedFabricationPartsWithInvalidConnections()).
Methods also exist to get and set the value of the fabrication dimension, to get the host element information and to get the fabrication rod information.
FabricationPart has a number of methods to attach to connectors or to change the position of the FabricationPart. The static StretchAndFit() method supports the operation to stretch the fabrication part from the specified connector and fit to the target routing end. The routing end is indicated as a FabricationPartRouteEnd object, which can be obtained from the static FabricationPartRouteEnd.CreateFromConnector() or FabricationPartRouteEnd.CreateFromCenterline() methods. If the StretchAndFit() method fails, it will return a FabricationPartFitResult enumeration that provides more details on the failure.
Other methods to modify the FabricationPart include Reposition(), RotateConnectedPartByConnector() and PlaceAsTap().
Some FabricationPart elements, such as purchased duct and pipe fittings, have a "product list". The product list entries represent a catalog of available sizes for the selected part. The ProductListEntry property specifies the product list entry of the FabricationPart. If the IsProductList() method returns false, the ProductListEntry will be -1.
To get the list of product entries for the FabricationPart, use the GetProductListEntryCount() and GetProductListEntryName() methods. Prior to changing the ProductListEntry for the FabricationPart, call IsProductListEntryCompatibleSize() to check to see if this part can be changed to the specified product list entry without altering any connected dimensions.