Revit provides a general mechanism for giving each element a set of parameters that you can edit.
In the Revit UI, some element parameters are visible in the Element Properties Palette. The following sections describe how to get and use built-in parameters, shared parameters and global parameters.
In the Revit Platform API, Parameters are managed in the Element class. You can access Parameters in these ways:
Common ways to get the value of a parameter are shown below. In this sample, all three lines of code get the same parameter. Because this parameter is stored as a string, the AsString() method is used to get its value.
private void GetStringParameterValue(Wall wall)
{
string s1 = wall.LookupParameter("Comments").AsString();
string s2 = wall.GetParameter(ParameterTypeId.AllModelInstanceComments).AsString();
string s3 = wall.get_Parameter(BuiltInParameter.ALL_MODEL_INSTANCE_COMMENTS).AsString();
}
Other ways to get a parameter are:
You can retrieve the Parameter object from an Element using the overloaded Parameter property if you know the built-in ID, definition, or GUID. The Parameter[GUID] property overload gets a shared parameter based on its Global Unique ID (GUID), which is assigned to the shared parameter when it's created.
The Element.LookupParameter() method gets a parameter based on its localized name, so your code should handle different languages if it's going to look up parameters by name and needs to run in more than one locale. Also, keep in mind that multiple matches of parameters with the same name can occur because shared parameters or project parameters can be bound to an element category even if there is already a built-in parameter with the same name. For this reason, it is better to use Element.GetParameters() which will return all parameters matching the given name. Element.LookupParameter() will return the first match found.
Parameters Service is a semi-automated, fully searchable database of design element parameters. Because Parameters Service lives in the Autodesk Construction Cloud, you can easily share it with teammates regardless of their physical location.
The class Autodesk.Revit.DB.ParameterDownloadOptions is an option class used for downloading parameters from the Parameters Service with the following properties:
These ParameterUtils methods provide functionality relevant to the Parameters Service: