GetFamilyTypeParameterValues Method


Returns all applicable values for a FamilyType parameter of this family.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.484.0)
Since: 2016

Syntax

C#
public ISet<ElementId> GetFamilyTypeParameterValues(
	ElementId parameterId
)
Visual Basic
Public Function GetFamilyTypeParameterValues ( _
	parameterId As ElementId _
) As ISet(Of ElementId)
Visual C++
public:
ISet<ElementId^>^ GetFamilyTypeParameterValues(
	ElementId^ parameterId
)

Parameters

parameterId
Type: Autodesk.Revit.DB ElementId
A valid Id of a FamilyType parameter defined for this family.

Return Value

Ids of all applicable ElementType and NestedFamilyTypeReference elements.

Remarks

The values are Element Ids of all family types that match the category specified by the definition of the given parameter. The elements are either of class ElementType or NestedFamilyTypeReference . The second variant is for the types that are nested in families and thus are not accessible otherwise.

If there are no applicable types of such category the returned collection will be empty.

Examples

Copy C#
public void GetNestedFamilyTypes(FamilyInstance instance)
{
    // find one FamilyType parameter and all values applicable to it

    Parameter aTypeParam = null;
    ISet<ElementId> values = null;

    Family family = instance.Symbol.Family;

    foreach (Parameter param in instance.Symbol.Parameters)
    {

        if (param.Definition.ParameterType == ParameterType.FamilyType)
        {

            aTypeParam = param;

            values = family.GetFamilyTypeParameterValues(param.Id);

            break;
        }
    }

    if (aTypeParam == null)
    {
        TaskDialog.Show("Warning", "The selected family has no FamilyType parameter defined.");
    }
    else if (values == null)
    {
        TaskDialog.Show("Error", "A FamilyType parameter does not have any applicable values!?");
    }
    else
    {
        ElementId newValue = values.Last<ElementId>();

        if (newValue != aTypeParam.AsElementId())
        {

            using (Transaction trans = new Transaction(instance.Document, "Setting parameter value"))
            {

                trans.Start();
                aTypeParam.Set(newValue);
                trans.Commit();
            }
        }
    }
}
Copy VB.NET
Public Sub GetNestedFamilyTypes(instance As FamilyInstance)
    ' find one FamilyType parameter and all values applicable to it


    Dim aTypeParam As Parameter = Nothing
    Dim values As ISet(Of ElementId) = Nothing

    Dim family As Family = instance.Symbol.Family

    For Each param As Parameter In instance.Symbol.Parameters

        If param.Definition.ParameterType = ParameterType.FamilyType Then

            aTypeParam = param

            values = family.GetFamilyTypeParameterValues(param.Id)

            Exit For
        End If
    Next

    If aTypeParam Is Nothing Then
        TaskDialog.Show("Warning", "The selected family has no FamilyType parameter defined.")
    ElseIf values Is Nothing Then
        TaskDialog.Show("Error", "A FamilyType parameter does not have any applicable values!?")
    Else
        Dim newValue As ElementId = values.Last()

        If newValue <> aTypeParam.AsElementId() Then

            Using trans As New Transaction(instance.Document, "Setting parameter value")

                trans.Start()
                aTypeParam.[Set](newValue)
                trans.Commit()
            End Using
        End If
    End If
End Sub

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The given parameterId does not represent a valid FamilyType parameter of this family.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL

See Also