Message 1 of 6
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am reloading families from disk based on a user selection, intending to allow easy updating to standard families. I want the parameters to remain unchanged, retaining the values set by the user. My implementation is below. The parameters are reset to the values being loaded no matter what I do. Apparently I am in over my head. I'm using python and the most excellent pyrevit library to run it. Thank you for your time.
from rpw.ui.forms import (Alert)
from Autodesk.Revit.DB import FamilySource, IFamilyLoadOptions
from rpw import ui, revit, DB, db
import clr
clr.AddReference('RevitAPI')
class FamilyOption(IFamilyLoadOptions):
def OnFamilyFound(self, familyInUse, overwriteParameterValues):
overwriteParameterValues = False
return True
def OnSharedFamilyFound(
self, sharedFamily, familyInUse, source, overwriteParameterValues):
source = FamilySource.Family
overwriteParameterValues = False
return True
sel = ui.Selection()
newfam = clr.StrongBox[DB.Family]()
if ui.Selection():
try:
famdoc = revit.doc.EditFamily(sel[0].Symbol.Family)
familypath = famdoc.PathName
famdoc.Close(False)
except Exception as e:
print (e)
if familypath:
with db.Transaction("Reload Family"):
revit.doc.LoadFamily(familypath,FamilyOption(),newfam)
Alert ("Family updated from: {}".format(familypath))
else:
Alert ("No External file to reload")
else:
Alert ("Nothing Selected")
Solved! Go to Solution.