Parameters 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: 17.0.0.0 (17.0.1090.0)

Syntax

C#
public ParameterSet Parameters { get; }
Visual Basic
Public ReadOnly Property Parameters As ParameterSet
	Get
Visual C++
public:
property ParameterSet^ Parameters {
	ParameterSet^ get ();
}

Remarks

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.

Examples

Copy C#
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.IntegerValue >= 0)
            {
                defValue = document.GetElement(id).Name;
            }
            else
            {
                defValue = id.IntegerValue.ToString();
            }
            break;
        case StorageType.Integer:
            if (ParameterType.YesNo == para.Definition.ParameterType)
            {
                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;
}
Copy VB.NET
Private Sub GetElementParameterInformation(document As Document, element As Element)
    ' Format the prompt information string
    Dim prompt As [String] = "Show parameters in selected Element: " & vbLf & vbCr

    Dim st As New StringBuilder()
    ' iterate element's parameters
    For Each para As Parameter In element.Parameters
        st.AppendLine(GetParameterInformation(para, document))
    Next

    ' Give the user some information
    TaskDialog.Show("Revit", prompt + st.ToString())
End Sub

Private Function GetParameterInformation(para As Parameter, document As Document) As [String]
    Dim defName As String = para.Definition.Name + vbTab & " : "
    Dim defValue As String = String.Empty
    ' Use different method to get parameter data according to the storage type
    Select Case para.StorageType
        Case StorageType.[Double]
            'covert the number into Metric
            defValue = para.AsValueString()
            Exit Select
        Case StorageType.ElementId
            'find out the name of the element
            Dim id As Autodesk.Revit.DB.ElementId = para.AsElementId()
            If id.IntegerValue >= 0 Then
                defValue = document.GetElement(id).Name
            Else
                defValue = id.IntegerValue.ToString()
            End If
            Exit Select
        Case StorageType.[Integer]
            If ParameterType.YesNo = para.Definition.ParameterType Then
                If para.AsInteger() = 0 Then
                    defValue = "False"
                Else
                    defValue = "True"
                End If
            Else
                defValue = para.AsInteger().ToString()
            End If
            Exit Select
        Case StorageType.[String]
            defValue = para.AsString()
            Exit Select
        Case Else
            defValue = "Unexposed parameter."
            Exit Select
    End Select

    Return defName & defValue
End Function

See Also