Let's veer away from the Revit API for a moment and take a look at family type catalogues, since questions on those pop up regularly in connection with programming as well:
- Programmatic type catalogue creation
- Tweaking type catalogue behaviour
- Type catalogue parameters
- Type catalogue units
Programmatic Type Catalogue Creation
Question: Is there any API support (function) to create type catalogues?
Answer: As far as I know, there are two ways to create type catalogues, and both are programmatically accessible:
- Create a TXT file associated with the family listing the possible combinations of dimensioning parameters.
- Create an MEP specific type catalogue for MEP parts.
I assume you are interested in the latter?
I tried searching the Revit API help for 'catalog', and that does indeed not return any relevant results.
However, searching the What's New listings, first for Revit 2015 and then for Revit 2014, turned up the following:
CSV Fitting Parameter Removal
Because CSV files are no longer used to drive MEP fitting parameters, Revit supports a new set of APIs to manage fitting parameters through several classes:
- FamilySizeTableManager – manages importing and exporting of legacy CSV data and size tables.
- FamilySizeTable – manages specific sizes of fittings.
- FamilySizeTableColumn – manages a specific dimension of a given size in a size table
- FamilySizeTableErrorInfo – reports any errors when importing an file with CSV size table into a FamilySizeTable
Is this possibly what you are looking for?
So maybe what you are after is the FamilySizeTable class and all its associated methods and properties.
Response: Actually we are interested in the first item, creating a TXT file associated with the family listing the possible combinations of dimensioning parameters.
Is there a way to create this txt file using Revit API?
Answer: That case is quite trivial, as far as I know:
Simply create a TXT file with the same name as the family definition RFA, and it will be picked up automatically by Revit.
I am not aware of any specific Revit API to achieve this or support it in any way.
To create the file, you can use standard .NET functionality, or anything else you like.
Basically this approach is simply making use of the standard family definition user interface functionality.
Tweaking Type Catalogue Behaviour
Question: Is there any support for TXT family type catalogue files inside Revit API?
If I use one of the LoadFamily methods and there is a TXT file along with the RFA, will the type selection dialogue pop up automatically?
Is there any way to tweak or suppress this behaviour?
Answer: While there isn't any support to handle the family type catalogue TXT files using the API, I was wondering if, instead of using LoadFamily, using LoadFamilySymbol to load up the specific symbols would work for you.
Alternatively, you can also load any single type from the family, programmatically duplicate it and modify the new type's parameters as you like.
Type Catalogue Parameters
Question: I have three questions related to type catalogues:
- The type catalogues created by Revit (using the UI button) have on the first line parameter names plus some extra information, e.g.,
Thickness##LENGTH##MILLIMETERS. What is the logic how that extra information is added and from where?
- When I look at the family parameters accessible from the family manager, I see some that are not present in the type catalogue. How do we know which parameters are and are not written to the type catalogue?
- Is there a validation mechanism for a type catalogue? How to check if is valid or not?
Answer: This information is about standard end user content creation and not at all Revit API related.
Therefore, you can probably find the answers yourself by researching those topics from an end user point of view.
I think this should help with your issues #1 and #2.
Regarding #3: it is indeed possible to create a poorly defined type catalogue.
That will get some sort of warning or error when you try to load such a family.
I am not aware of any other way to check or validate via API or otherwise.
Loading a family with a type catalog displays the dialogue 'Specify Types':
The grid under the types section is driven directly from the type catalog. If the type catalog includes additional parameters that are not in the family, a warning is displayed and they are ignored.
Type Catalogue Units
Question: we're trying to create type catalogue in txt file for Radiator family. We were trying to define a parameter in watt units, with no success. How to define header for this parameter?
Answer: Look at page 15 of Martin Schmid's Autodesk University class handout on Creating Revit MEP Content for Engineering Coordination.
They don't use Watts, but should give the idea if you are not already familiar with type catalogues.
Also, the families guide provides a list of the parameter types, namely, for electrical_power: watts, kilowatts, british_thermal_units_per_second, british_thermal_units_per_hour, calories_per_second, kilocalories_per_second, volt_amperes, kilovolt_amperes, horsepower.
Thus, the header definition for such a parameter would be: