Returns all applicable values for a FamilyType parameter of this family.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 22.0.0.0 (22.1.0.0)
Since:
2016
Syntax
Remarks
Examples
CopyC#
public void GetNestedFamilyTypes(FamilyInstance instance)
{
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();
}
}
}
}
CopyVB.NET
Public Sub GetNestedFamilyTypes(instance As FamilyInstance)
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 Category.IsBuiltInCategory(param.Definition.GetDataType()) 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
See Also