Hi,
We’ve written a Dynamo graph based on Erfajo’s excellent responses to Load Revit families from list. We’ve tweaked it so that it should load families without Overwriting the type parameters of families already loaded. Unfortunately this isn’t working and the Python script still overwrites the type parameters on reloading the family.
My Python skills are poor and can’t see why “overwriteParameterValues = False” doesn’t seem to stick. I’m hoping there’s an obvious bug that someone can point out?
import clr
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
#Inputs is stored in the IN variable
elements = IN[0]
#Ensure loaded families can overwrite existing families.
class FamilyOption(IFamilyLoadOptions) :
def OnFamilyFound(self, familyInUse, overwriteParameterValues) :
overwriteParameterValues = False
return True
def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues) :
overwriteParameterValues = False
return True
#Core data processing
TransactionManager.Instance.EnsureInTransaction(doc)
opts = FamilyOption()
for element in elements :
doc.LoadFamily(element, opts)
TransactionManager.Instance.TransactionTaskDone()
#The result (log) to the OUT variable
OUT = "Famil{} updated/reloaded".format('y is' if len(IN[0]) == 1 else 'ies are')
Ideally we would also have a boolean toggle going into the Python node which would set overwriteParameterValues to true or false as required. I notice that the dynamo node outputs lower case values e.g. “false” whilst Python required capitalised values e.g. “False” and is case sensitive. Would this work and is there a simple IF conditional that can/should be used to translate these?
Thanks!