One common frustration in Revit is the need to create a family within the family editor and then import it into a project. Is there a way to create a family directly inside the project environment and place it at the desired location without importing it separately? Fortunately, this is possible.
To achieve this, the process involves two main steps through coding:
- Open the family file and create the family in the family editor environment;
- Load the family into the project environment and place it at the intended location.
Let’s start with the first step, which involves implementing the IFamilyLoadOptions interface.
Here is a sample class:
using System;
using Autodesk.Revit.UI;
using Autodesk.Revit.DB;
namespace RoadFoundationPlugin
{
public class ProjectFamLoadOption : IFamilyLoadOptions
{
bool IFamilyLoadOptions.OnFamilyFound(bool familyInUse, out bool overwriteParameterValues)
{
overwriteParameterValues = true;
return true;
}
bool IFamilyLoadOptions.OnSharedFamilyFound(Family sharedFamily, bool familyInUse, out FamilySource source, out bool overwriteParameterValues)
{
source = FamilySource.Project;
overwriteParameterValues = true;
return true;
}
}
}
Within the project, the first step is to open the family file, then load it and overwrite any existing parameters if necessary.
Document familyDoc = revitApp.NewFamilyDocument(@"C:ProgramDataAutodeskRVT 2016Family TemplatesChineseAdaptive metric conventional model.rft");
Family loadedFamily = familyDoc.LoadFamily(revitDoc, new ProjectFamLoadOption());
The final step is to instantiate the loaded family within the project at the desired location.
Here is an example of the implementation result: see __AI_S_TURL_0__













Must log in before commenting!
Sign Up