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

#22

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
";


0 Likes

#23

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

#25

@erfajo, Sorry, I edited the post

0 Likes

#27

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

0 Likes