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

Hi All,

Time for asking questions…

I have multiple revit models (2017) and they are all in a folder and I also have families located on a folder.

What I want is simple enough (I think) but I am stuck. I want to load all families from a folder BUT to all Revit Models from a folder. I am not upgrading my families nor my revit models just simply loading families on different models, save and close each model with the loaded families.

I used this graph found in
https://forum.dynamobim.com/t/load-multiple-families-from-a-folder/11906/5

and changed the DOC input to use Rhythm open document on background but it only do one at a time as I cannot figure out how to do a FOR EACH in the Document list and I also need to unwire everytime I need to save.

see below image and graph

have to do it one by one to work

dyn…
loadFamilyv2.dyn (10.7 KB)

thanks in advance…

Hi @4bimfercesp

Use @List levels for Document.BackGroundOpen if you have multiple lists.

Hi kulkul

Thanks a lot, i dont follow you. There is a python code on this graph and only accept one doc at a time and it does not save. This is where i am stuck. Is there any OOTB can do this tasks?

So modify the python to accept lists instead of individual elements? Or make it a custom node and try to work with lacing to get the right results?

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.

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

@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.

@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");
			t1.Start();
			foreach(string famFile in famFiles) {
				doc1.LoadFamily(famFile);
			}
			t1.Commit();
			doc1.Close();
		}
	}
4 Likes

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.

4 Likes

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

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

2 Likes

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
clr.AddReference(‘ProtoGeometry’)
import Autodesk.DesignScript as AD
from Autodesk.DesignScript.Geometry import *

clr.AddReference(‘RevitAPI’)
from Autodesk.Revit.DB import *

clr.AddReference(‘RevitServices’)
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 :
TransactionManager.Instance.EnsureInTransaction(doc)

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

TransactionManager.Instance.ForceCloseTransaction()

#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


22
Link:https://awaygroup-my.sharepoint.com/:u:/g/personal/quoc_nguyen_draftaway_com_au/EXuJ6J5ivhBGqwx4x9corlYBPtA_-2fRyUrEo35aZdtlgA?e=FhKAI2

3 Likes

@erfajo, Sorry, I edited the post

Hi,
This post it s old, but I need the node “File Load Family”, and it doesnt exist in the Orchid package anymore.
There is another that it s “Document Load Family”, but the output is a document, so it is not loading my families in the different documents.
So it s not working as expected.
There is a way to do this???

Thank you!