BIM World
A Professional BIM Learning Platform


Revit API: Creating Families Directly Within Project Environment

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:

  1. Open the family file and create the family in the family editor environment;
  2. 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__

xuebim
Follow the latest BIM developments in the architecture industry, explore innovative building technologies, and discover cutting-edge industry insights.
← Scan with WeChat
Like(0) 打赏
BIM WORLD » Revit API: Creating Families Directly Within Project Environment

Comment Get first!

Must log in before commenting!

 

BIM World, A Professional BIM Learning Platform

Stay updated on the latest architecture trends and share new building technologies.

Contact UsAbout Us

觉得文章有用就打赏一下小编吧

非常感谢你的打赏,我们将继续提供更多优质内容,让我们一起创建更加美好的网络世界!

支付宝扫一扫

微信扫一扫

Account Login

By signing in, you agree toUser Agreement

Sign Up