Relaod families in revit using dynamo

Hello, I’ve created a script to reload families used in a Revit project. It works, and the families are reloaded with the changes made to their “.rfa files”. However, the script doesn’t update changes in values for model parameters (it only updates changes in geometry). Do you have any ideas on how I can resolve this issue?


Is this reload node a node from genius loci?

The overwrite parameter values should be set to true, so it should work.

Edit: Genius Loci node works as expected for me in Revit 23

#Alban de Chasteigner 2020
#twitter : @geniusloci_bim
#geniusloci.bim@gmail.com
#https://github.com/albandechasteigner/GeniusLociForDynamo

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import Document, FamilySource, IFamilyLoadOptions

clr.AddReference('RevitServices')
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

famDocs = IN[0] if isinstance(IN[0],list) else [IN[0]]
output = []
#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 famDoc in famDocs:
	if isinstance(famDoc, basestring):
		TransactionManager.Instance.EnsureInTransaction(doc)
		output.append(doc.LoadFamily(famDoc,FamilyOption()))
		TransactionManager.Instance.TransactionTaskDone()
	else:
		TransactionManager.Instance.ForceCloseTransaction()
		output.append(famDoc.LoadFamily(doc, FamilyOption()))
	
OUT = output

yes the reload node is a node from genius loci and unforunately it dosen’t overwrite values of existing parameters ,if i create another parametr in rfa family it work but when i change a value of an exisisting parametre it dosen’t work !
I work also with revit 2023, Should i try to create manualy the node with python code that you have create ?

This is the exact code from the node, so I´m afraid it also wont work for you.
I have no idea what the problem could be, sorry.

thank you Mr.Gerhard .
I tried to take a screenshot to see the problem. I hope that some of you have an idea about the cause of this.

Mr gerhard can you tell me the version of genius loci that you are working with ?

Does it work if you load the family manually, without dynamo?

yes it works perfectly when i load the family manuallay by clicking on ''change family and parameter"

very strange.
This is my version:

image

i will try tomorrow to work with the same version that you have and see the result, thank yu a lot Gerhard

A few thoughts;

  • Are you saving your RFA file before loading? The script is loading in the file from disk/ storage
  • Do you have the IronPython 2.7 Package installed? Sub-classing (class FamilyOption(IFamilyLoadOptions)) .NET classes only works in IronPython 2.7
2 Likes

Important to note that values will only update if the family would trigger the overwrite dialogue when loading back to Revit. If you’re just trying to load new types or update values to default after changing in the project environment that wont work as the family reload wont recognize any changes between project/family versions.

If there are changes then the IFamilyLoadOptions interface can help:

This is an example I use in pyRevit tools to take on family values on load, so ignore the DB’s. This can be provided as the options for the load/reload methods. Interfaces are a bit tricky, but they are effectively like a class that is designed to return inputs to interfaces in Revit based on the options they will have available:

class FamilyOptionsFamily(DB.IFamilyLoadOptions):
	# If family is found, overwrite the options
	def OnFamilyFound(self, familyInUse, overwriteParameterValues):
		overwriteParameterValues = True
		return True
	# If shared family is found, overwrite the options
	def OnSharedFamilyFound(self, sharedFamily, familyInUse, source, overwriteParameterValues):
		overwriteParameterValues = True
		source = DB.FamilySource.Family
		return True
1 Like

Hi @alienau2016 probably something here could help

1 Like

Thank you very much to all of you.
I found the issue. In fact, when I make changes to the parameter values in the RFA file, I return to the project environment without closing the RFA file. As a result, the changes are not applied.
However, when I tried making the changes after that i close the RFA file and running the script in the project environment, it worked perfectly.
Thank you and have a great day :smiley:

1 Like

thank you Mr.Mike :smiley:
yes i have the package IronPython 2.7, it was a problem of closing the RFA file after doing the changes.

thank you Gavin :smiley:

thank you @sovitek i willtry to work with this script also .