Hello All,
I receive models which have links located on BIM360 storage. I place the linked files to the same folder with the host file. Now I need to reload links from that folder. I created a script for that, but it doesn’t work. Please advise.
import os.path
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Analysis import *
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
links= UnwrapElement(IN[0])
#names= UnwrapElement(IN[1])
folder = BasicFileInfo.Extract(doc.PathName).CentralPath
folder = os.path.dirname(folder)
config = WorksetConfiguration(WorksetConfigurationOption.OpenLastViewed)
listOut = []
listOut.append("CENTRAL FILE LOCATION: " + folder)
i = 0 # index
for t in links:
# name = names[i]
name = t.GetParameters("Type Name")[0].AsString()
i = i + 1
n = name.find('.rvt')
if n>1:
name=name[0:n+4]
name=name.replace("_detached","")
if os.path.isfile(folder + "\\" + name) :
# fp=name
fp=folder + "\\" + name
fpm=ModelPathUtils.ConvertUserVisiblePathToModelPath(fp)
# remove BIM360 path
try:
t.LoadFrom(fpm, config)
listOut.append("LOADED: " + name)
except:
listOut.append("Link Fail: " + fp)
# Set path to Relative
try:
t.PathType = PathType.Relative
except:
name=name
OUT= listOut
Thank you.