When I try to run loadfrom with modelpath but I keep getting an error asking for ExternalResourceReference. I’m creating the modelPath with the ModelPathUtils.ConvertUserVisiblePathToModelPath method. Is the issue here that it is actually creating a FilePath instead of a ModelPath? I thought that ModelPathUtils would have created a model path.
Here is my print statement with the error:
Temp-HVAC23.rvt needs reloading!
<Autodesk.Revit.DB.FilePath object at 0x0000000000004A63 [Autodesk.Revit.DB.FilePath]>
Autodesk.Revit.DB.FilePath
IronPython Traceback:
Traceback (most recent call last):
File "L:\Revit\Development\PyRevit\DevTool\DevTool.extension\DevTools.tab\Development.Panel\StartReloadFrom.pushbutton\StartReloadFrom_script.py", line 149, in <module>
TypeError: expected ExternalResourceReference, got FilePath
for lT in linkTemp:
for lTRF in linksToReloadFrom:
if lT.name == lTRF:
actualLinksReload.append(lT)
print(lT.name + " needs reloading!")
# print(lT.linkDicIndex)
fileReloadName = file.replace(docNameDis, linkDic[lT.linkDicIndex][0])
# print(fileReloadName)
pathReloadString = folder + fileReloadName
pathReload = ModelPathUtils.ConvertUserVisiblePathToModelPath(pathReloadString)
print(pathReload)
print(pathReload.GetType())
linkType = doc.GetElement(lT.link.GetTypeId())
# print(linkType)
linkType.LoadFrom(pathReload, WorksetConfiguration)
Am I misunderstanding the question? What does print(pathReloadString) return? Error indicates the wrong overload is being used because you didn’t provide a valid modelpath
This feature is something most people don’t know about, even though, I show it every time I got to speak in public.
if you go on this page, for example, you will find a small <> (Chevrons) sign at the top right of the page.
It uses the github API search feature to go through a defined list of website having Revit API related C# and python code:
and its python counterpart https://python.hotexamples.com/
but be aware, in pyRevit, code is mostly iron python, mostly around the revit API, which is very niche.