RVTDocs.com
Namespace: Autodesk.Revit.DB Class: Family

Family.GetFamilyTypeParameterValues

Method
Description:
Returns all applicable values for a FamilyType parameter of this family.
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.

Syntax
Examples
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 (Category.IsBuiltInCategory(param.Definition.GetDataType()))
        {

            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();
            }
        }
    }
}
Parameters
Parameter Type Description
parameterId ElementId A valid Id of a FamilyType parameter defined for this family.
Return Value
Type Description
ISet Ids of all applicable and elements.
Exceptions
Exception Condition
ArgumentException The given parameterId does not represent a valid FamilyType parameter of this family.
ArgumentNullException A non-optional argument was null