DocumentLoadFamily(String, Family) Method |
Loads an entire family and all its types/symbols into the document and provides a reference
to the loaded family.
Namespace: Autodesk.Revit.DBAssembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntaxpublic bool LoadFamily(
string filename,
out Family family
)
Public Function LoadFamily (
filename As String,
<OutAttribute> ByRef family As Family
) As Boolean
public:
bool LoadFamily(
String^ filename,
[OutAttribute] Family^% family
)
member LoadFamily :
filename : string *
family : Family byref -> bool
Parameters
- filename String
- The fully qualified filename of the Family file, usually ending in .rfa.
- family Family
- A reference to the family that was loaded if successful, otherwise .
Return Value
BooleanTrue if the entire family was loaded successfully into the project, otherwise False.
Exceptions
RemarksLoading 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.
Example
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;
Autodesk.Revit.UI.TaskDialog.Show("Revit","Family file has been loaded. Its name is " + name);
}
else
{
Autodesk.Revit.UI.TaskDialog.Show("Revit","Can't load the family file.");
}
}
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
UI.TaskDialog.Show("Revit", "Family file has been loaded. Its name is " & name)
Else
UI.TaskDialog.Show("Revit", "Can't load the family file.")
End If
End If
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also