Using Revit API and without using Revit UI, I want to save a loaded family into a new file.
Let's take a look at the following code:
using (Transaction transaction = new Transaction(document))
{
transaction.Start("Load and Save Family");
if (document.LoadFamily(familyFullPath, out Family family))
{
Console.Writeline("Load successful")
}
transaction.Commit();
ModelPath newPath = ModelPathUtils.ConvertUserVisiblePathToModelPath("result.rfa");
SaveAsOptions saveAsOptions = new SaveAsOptions();
family.Document.SaveAs(newPath, saveAsOptions);
}
The problem with this code is that it saves the default document in which we load the family, because family.Document
is returning "the document in which the element resides".
What I want to do is to save only the loaded Family
as a new .rfa
document.
To explain better, I will demonstrate what it looks like when using Revit UI:
How can I achieve the same thing but purely with Autodesk.Revit.DB
?