Load multiple Families from a folder and to multiple Revit Models from a folder

Yes i did this already…as each revit model is already opened (all in the folder) at the background it wont grab it (for each trick in python). Lacing does not work i tried that also. Due to same reason…i will retry it again maybe i missed something.

List level is activated by the small arrows on the nodes.

accepting more than one element means that you need to implement a loop

one element =>
IN[0].element do something

several elements =>
for i in IN[0]
i.element do something

1 Like

I have tried to solve this problem, but has run into the “current document” problem. The attach graph load families in the current project… but if someone has an idea to code the node there can take loaded documents and make them active so Dynamo can work on them is it appreciated.

I have an idea that I need to change something in @john_pierson node “BackgroundOpen” or take its output and set it active somehow…

my graph so far…
ProjectLoadFamily.dyn (14.7 KB)

@4bimfercesp you could also try to see this solution by @Andreas_Dieckmann. He has made a solution for opening multiple files… maybe it could be combined with my LoadFamily.


DynamoAutomation unfortunately does not perform reliably on top of Revit 2017.
For Revit 2016, this would indeed work.

As far as I understand @Andreas_Dieckmann, it isnt possible to change the “current project” except if you open a new session…

Meaning using the OpenAndActivateDocument method or something similar.
I have an idea that is what you have done in your DynamoAutomation.

If that is the case, then I would suggest you @4bimfercesp to open the projects manually and then run LoadFamily. If @Andreas_Dieckmann manage to get DynamoAutomation going for 2017 and 2018, then try combining these solution :slight_smile:

You can take my previous graph and remove before and after the red block :slight_smile:

@erfajo many thanks for your efforts, I will do as you suggested just open the documents and apply your original solution and be done with it.

thanks to all.

Your are welcome, but I somehow hope that @Andreas_Dieckmann will get his DynamoAutomation going for 2017 and 2018 or the dynamoteam will provide a solution for setting the current document.

@erfajo, it seems like you can open and activate. http://www.revitapidocs.com/2018/3b3d671d-47ec-2ed8-1818-a7c19d01884b.htm

@4bimfercesp This is probably not the political correct answer here on the Dynamo forums, but it is quite easy to achieve with an application macro in Revit. Run it without any documents open i Revit.

	public void BatchAddFamilies()
		string[] files = {@"C:\Users\eibre\Desktop\revit\opendoc\RIB.rvt", @"C:\Users\eibre\Desktop\revit\opendoc\ark.rvt"};
		string[] famFiles = {@"C:\Users\eibre\Desktop\revit\opendoc\hexagon.rfa",@"C:\Users\eibre\Desktop\revit\opendoc\triangle.rfa"};
		foreach (string file1 in files) {
			Document doc1 = Application.OpenDocumentFile(file1);
			Transaction t1 = new Transaction(doc1,"Load family");
			foreach(string famFile in famFiles) {

Thanks a lot i will try this…it looks really simple i used to do a lot of macro with revit. But now my attention is with dynamo as i can involve none revit programmers as dynamo is more visual which everyone can easily grasp than macro although some may say its the opposite. Thanks again i have now both macro and dynamo to use in order to solve my open document background or multiple open revit and run tasks on it. I know it may not be possible but its fun otherwise. Thanks

Hi All,
Finally broke the Code…I can now open and load families or even run tasks on multiple revit models. Just want to share the great news.

Will be posting the code in the coming days just making sure it is working 100% before I share. Special thanks to @Einar_Raknes and @erfajo who helped me figure it out.

Let the good times roll…also thanks to @Konrad_K_Sobon and @Daniel_Woodcock1 for sharing their python code which enables me to come up with the workflow.

watch the space…
thanks again to the community.


sorry for answering so late… but the syntax is not correct in your post according to the API.
I used also the wrong syntax until recently :slight_smile:

This is the correct use in the post
public Family LoadFamily( Document targetDocument )

If present families must be overwritten, then use this syntax.
public Family LoadFamily( Document targetDocument, IFamilyLoadOptions familyLoadOptions )

For updated code for family loading please see here.

@erfajo Do you mean that doc1.LoadFamily(famFile) should be famFile.LoadFamily(doc1) ?

yes… exactly :slight_smile:
try to see Jeremy Tammik

@erfajo FYI: There’s a new DynamoAutomation version out now that is compatible with Revit 2017 & 2018.


Hi Andreas,

Thanks for the update, however I did not used the Dynamo Automation to solve my topic. I have made a different approach on the loading multiple families from a folder and load them to multiple Revit models.

Thanks again for your hard work.

Hi @4bimfercesp
Were you able to find a solution to this?

I was trying something like the below. I am trying to piece together python - this doesn’t work at the moment.
Any suggestions?

import clr
import Autodesk.DesignScript as AD
from Autodesk.DesignScript.Geometry import *

from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

#input assigned the IN variables
paths = IN[0]
docs = IN[1]

#wrap input inside a list (if not a list)
if not isinstance(paths, list): paths = [paths]

#ensure loaded families can overwrite existing families.
class FamilyOption(IFamilyLoadOptions):
def OnFamilyFound(self, familyInUse, overwriteParameterValues):
overwriteParameterValues = True
return True

def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues):
	source = FamilySource.Family
	overwriteParameterValues = True
	return True

for doc in docs :

#core data processing
for path in paths:
famDoc = app.OpenDocumentFile(path)
famDoc.LoadFamily(doc, FamilyOption())


#output assigned the OUT variable
OUT = paths, docs

I have a simple node that solves this problem. please share
I use the node “LoadFamily (document, family) of the Orchid package”
p / s: Please select Lacing - longest



@erfajo, Sorry, I edited the post

good… I have also in the meantime updated my package with more new nodes (for system families)