Loads an entire family and all its types/symbols into the document and provides a reference to the loaded family.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 24.0.0.0 (24.0.0.0)
Syntax
C# |
---|
|
Visual Basic |
---|
|
Visual C++ |
---|
|
Parameters
- filename
- Type: SystemString
The fully qualified filename of the Family file, usually ending in .rfa.
- family
- Type: Autodesk.Revit.DBFamily%
A reference to the family that was loaded if successful, otherwise a null reference (Nothing in Visual Basic).
Return Value
True if the entire family was loaded successfully into the project, otherwise False.Remarks
Loading an entire family may take a considerable amount of time and memory. It is recommended that you use one of the LoadFamilySymbol() methods and only load those symbols that you need.
Examples

// Get the Revit library path as defined via the Options dialog - File Locations tab - Places button
string libraryPath = "";
application.Application.GetLibraryPaths().TryGetValue("Imperial Library", out libraryPath);
if (String.IsNullOrEmpty(libraryPath))
{
libraryPath = "c:\\"; // If not have, use a default path.
}
// Allow the user to select a family file.
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = libraryPath;
openFileDialog1.Filter = "Family Files (*.rfa)|*.rfa";
// Load the family file using LoadFamily method and then give information.
if (DialogResult.OK == openFileDialog1.ShowDialog())
{
Autodesk.Revit.DB.Family family = null;
if (document.LoadFamily(openFileDialog1.FileName, out family))
{
String name = family.Name;
TaskDialog.Show("Revit","Family file has been loaded. Its name is " + name);
}
else
{
TaskDialog.Show("Revit","Can't load the family file.");
}
}

' Get the Revit library path as defined via the Options dialog - File Locations tab - Places button
Dim libraryPath As String = ""
application.Application.GetLibraryPaths().TryGetValue("Imperial Library", libraryPath)
If [String].IsNullOrEmpty(libraryPath) Then
' If not have, use a default path.
libraryPath = "c:\"
End If
' Allow the user to select a family file.
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = libraryPath
openFileDialog1.Filter = "Family Files (*.rfa)|*.rfa"
' Load the family file using LoadFamily method and then give information.
If DialogResult.OK = openFileDialog1.ShowDialog() Then
Dim family As Autodesk.Revit.DB.Family = Nothing
If document.LoadFamily(openFileDialog1.FileName, family) Then
Dim name As [String] = family.Name
TaskDialog.Show("Revit", "Family file has been loaded. Its name is " & name)
Else
TaskDialog.Show("Revit", "Can't load the family file.")
End If
End If
Exceptions
Exception | Condition |
---|---|
Autodesk.Revit.ExceptionsArgumentException | Thrown when filename is a null reference (Nothing in Visual Basic) or empty. |