How to ensure a family used by a graph is in the current model?

While learning how to make custom nodes I remember hearing that the “extras” folder can carry any files that are needed. If I put a family that is used for annotation in a graph in that folder how would I make sure it is loaded in the model before trying to use it?

I was expecting automagic, but if I have to just load it first I can do that.

Hi @steven.jensen !
Here is a little graph to check if a family or a specific type is in the moel

1 Like

Merci. The FamilyType.ByName is what I am using later in my graph to perform the work as well.

If there is no magic way to reference the “extras” folder, I guess I can just load up the family first.

Throwing Revit families in an “extras” folder doesn’t put it in the project.
The “extras” folder you are referring to is for Dynamo code.

You can however load a family into a project file using Dynamo from a known folder. Look at the Clockworks node, LoadFamily. There are other packages as well.

So you can have the graph look for the family, and if not loaded - load it from any directory you want to put it in and then do whatever you are wanting to do with it.

You can also use the LoadFamily() method in Python to load the family into the document.

I think my question was poorly stated. I am wondering if there is a static reference, or programmatic way to refer to the family that I have in the extras folder?

Similar to an image file used by a package, or the custom package icon. Is it possible to load it from the path .\packages\my package\extras or something? I am finding that packages can be found in many places, and customized for every installation.

I have my package folders configured, but when I use Orkestra cloud version a new path for packages is added. I don’t know how to account for changes like that when trying to load the family.

Shouldnt Revit Content be in a central Revit content library? Doing this will mitigate the need to have a thing that varies depending on the dynamo and revit version.

If you do the above i would then check the revit version then go to a content location that is dependent on that version. Then from a string search that directory for files that match the given string, then load that in(if that is what you want to do).

Though prior to loading it in i would do a check as indicated earlier in this topic to check for if that family exists in the revit project, then only load it in once it has been confirmed it does not exist in the revit project.

Right now my graph does pull from a central library, and I check to see if it is loaded in the project, but that limits the use to people on my network. I have configured a system variable on the PCs via group policy so I can refer to the central library %revitlibrary%\families\yearversion\family.rfa. This allows me to have a static path the file on any of our offices servers no matter what the drive mapping is at that office.

Since my custom package gets stored someplace different for each version of revit dynamo having the family be the correct year shouldn’t be an issue. I am just looking for that static path to extras folder so people not connected to my network have someplace to check for the family before trying to use it.

I would suggest you have a look at the below code and modify it to what you want as it may partially help you.

Wow, that is pretty comprehensive. Thanks, that does look promising.