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# |
---|
public bool LoadFamily(
string filename,
out Family family
) |
Visual Basic |
---|
Public Function LoadFamily ( _
filename As String, _
<OutAttribute> ByRef family As Family _
) As Boolean |
Visual C++ |
---|
public:
bool LoadFamily(
String^ filename,
[OutAttribute] Family^% family
) |
Parameters
- filename
- Type: System..::..String
The fully qualified filename of the Family file, usually ending in .rfa.
- family
- Type: Autodesk.Revit.DB..::..Family%
A reference to the family that was loaded if successful, otherwise nullNothingnullptra null reference (Nothing in Visual Basic).
Return Value
True if the entire family was loaded successfully into the project, otherwise False.
Remarks
Examples
CopyC#
string libraryPath = "";
application.Application.GetLibraryPaths().TryGetValue("Imperial Library", out libraryPath);
if (String.IsNullOrEmpty(libraryPath))
{
libraryPath = "c:\\";
}
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = libraryPath;
openFileDialog1.Filter = "Family Files (*.rfa)|*.rfa";
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.");
}
}
CopyVB.NET
Dim libraryPath As String = ""
application.Application.GetLibraryPaths().TryGetValue("Imperial Library", libraryPath)
If [String].IsNullOrEmpty(libraryPath) Then
libraryPath = "c:\"
End If
Dim openFileDialog1 As New OpenFileDialog()
openFileDialog1.InitialDirectory = libraryPath
openFileDialog1.Filter = "Family Files (*.rfa)|*.rfa"
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
See Also