Element.Parameters
Public Property
Retrieves a set containing all of the parameters that are contained within the element.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
public ParameterSet Parameters { get; }
Property Value
ParameterSetRemarks
The Parameters property contains a set of all the parameters that the element supports. These parameters are displayed in the Element properties dialog in the Autodesk Revit interface. These parameters can be retrieved and set via the parameter objects stored in this set.
Example
void GetElementParameterInformation(Document document, Element element){ // Format the prompt information string String prompt = "Show parameters in selected Element: \n\r";
StringBuilder st = new StringBuilder(); // iterate element's parameters foreach (Parameter para in element.Parameters) { st.AppendLine(GetParameterInformation(para, document)); }
// Give the user some information TaskDialog.Show("Revit", prompt + st.ToString());}
String GetParameterInformation(Parameter para, Document document){ string defName = para.Definition.Name + "\t : "; string defValue = string.Empty; // Use different method to get parameter data according to the storage type switch (para.StorageType) { case StorageType.Double: //covert the number into Metric defValue = para.AsValueString(); break; case StorageType.ElementId: //find out the name of the element Autodesk.Revit.DB.ElementId id = para.AsElementId(); if (id != ElementId.InvalidElementId) { defValue = document.GetElement(id).Name; } else { defValue = id.ToString(); } break; case StorageType.Integer: if (SpecTypeId.Boolean.YesNo == para.Definition.GetDataType()) { if (para.AsInteger() == 0) { defValue = "False"; } else { defValue = "True"; } } else { defValue = para.AsInteger().ToString(); } break; case StorageType.String: defValue = para.AsString(); break; default: defValue = "Unexposed parameter."; break; }
return defName + defValue;}