Cannot set parameter in linked Revit files - Third Party Updater
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello
I created a dynamo script that sets any room parameter in linked Revit files. The script works perfect, you run it on a “master model” with several linked files, select one of them and set a parameter name you would like to change - I am transfering name of the level where the room is located to one of its instance parameters. Dynamo opens the project on a background, set the parameters and loads the project back to the master. The script works perfect, when I test it with a blank project based on AC template.
The problem is that when I run the script on a certain project (it is very old project that is in the process many years - many versions of Revit), the link file unloads, the parameters are set, but it crashes when Dynamo wants to load the project back to the master model.
I figured out, that the problem might be in Third Party Updater. The Journal file says that the Third Party Updater ‘Revit: ObjectNumberingUpdater’ has been unregistered. I do not have any addins installed, and I believe that the problem might be, that someone in the past installed some addin to Revit, used it on this project, and then uninstall it. (Tested on revit 2022 and 2023)
I attach the journal file and also the Python script that does the job.
Anyone has any idea? Maybe it is possibble to figure this out with Python. Thank you for all the help.
Lucie
import clr
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
app = DocumentManager.Instance.CurrentUIApplication.Application
link = UnwrapElement(IN[0])
parname = IN[1]
val = IN[2]
linkPath = link.GetLinkDocument().PathName
linkType = doc.GetElement(link.GetTypeId())
TransactionManager.Instance.ForceCloseTransaction()
linkType.Unload(None)
linkDoc = app.OpenDocumentFile(linkPath)
el = FilteredElementCollector(linkDoc).OfCategory(BuiltInCategory.OST_Rooms).WhereElementIsNotElementType().ToElements()
TransactionManager.Instance.EnsureInTransaction(linkDoc)
for e,v in zip(el,val):
e.LookupParameter(parname).Set(v)
TransactionManager.Instance.TransactionTaskDone()
TransactionManager.Instance.ForceCloseTransaction()
linkDoc.Close()
linkType.Reload()
OUT = linkDoc