Hi!
I’m having some issues with automatic stairs path tags when they’re in a linked model.
When the stairs is in the same model, there’s no problem, but when it’s in a linked model, the script fail and I can’t guess why.
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
#Import DocumentManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
#Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB.Architecture import *
#Import ToDSType(bool) extension method
clr.AddReference("RevitNodes")
import Revit
from Autodesk.Revit.DB import *
from Autodesk.Revit.Creation import *
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
toList = lambda x : x if hasattr(x, "__iter__") else [ x ]
views = UnwrapElement(toList(IN[0]))
typelist = list()
newpaths = list()
escVinc2 = UnwrapElement(IN[1])
vinculos = FilteredElementCollector(doc).OfClass(RevitLinkInstance).ToElements()
#vinc = vinculos[1]
documentos = [x.GetLinkDocument() for x in vinculos]
prueba,prueba2 = [],[]
escaleras = []
for view in views:
aux = []
nivel = view.GenLevel
bip1 = BuiltInParameter.STAIRS_BASE_LEVEL_PARAM
bip2 = BuiltInParameter.STAIRS_TOP_LEVEL_PARAM
prov1 = ParameterValueProvider(ElementId(bip1))
prov2 = ParameterValueProvider(ElementId(bip2))
eva = FilterNumericEquals()
regla1 = FilterElementIdRule(prov1,eva,nivel.Id)
regla2 = FilterElementIdRule(prov2,eva,nivel.Id)
filtro1 = ElementParameterFilter(regla1)
filtro2 = ElementParameterFilter(regla2)
filtro = LogicalOrFilter(filtro1,filtro2)
#fec = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Stairs).WhereElementIsNotElementType().ToElements()
fec = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Stairs).WherePasses(filtro).WhereElementIsNotElementType().ToElements()
#nivel=view.LookupParameter("Nivel asociado").AsString()
#nivel = view.get_Parameter(BuiltInParameter.PLAN_VIEW_LEVEL)
"""
for e in fec:
if e.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM)==nivel:# or e.get_Parameter(BuiltInParameter.STAIRS_TOP_LEVEL_PARAM)==nivel:
#if e.LookupParameter("Nivel base")==nivel or e.LookupParameter ("Nivel superior")==nivel:
aux.append(e)
aux.append(e.get_Parameter(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM))
#aux.append(e.GetParameterValue(BuiltInParameter.STAIRS_BASE_LEVEL_PARAM))
"""
escaleras.append(fec)
TransactionManager.Instance.EnsureInTransaction(doc)
#find stairpathtype
fec = FilteredElementCollector(doc)
filtro = ElementCategoryFilter(BuiltInCategory.OST_StairsPaths)
caminosTipos = fec.WherePasses(filtro).ToElements()
for tipo in caminosTipos:
istype = tipo.ToString()
if istype == "Autodesk.Revit.DB.Architecture.StairsPathType":
typelist.append(tipo)
stairpathtype = typelist[0]
pathid = stairpathtype.Id
#pathid = FilteredElementCollector(doc).OfClass(StairsPathType).WhereElementIsElementType().FirstElementId()
#create stair path for stair runs
# esto es para escaleras en modelo
for v,e in zip(views,escaleras):
for escalera in e:
stairid = LinkElementId(escalera.Id)
try:
newpath = StairsPath.Create(doc, stairid, pathid, v.Id)
newpaths.append(newpath)
except:
pass
"""
for escalera in escVinc2:
try:
stairid = LinkElementId(escalera.Id)
newpath = Autodesk.Revit.DB.Architecture.StairsPath.Create(escalera.Document, stairid, pathid, v.Id)
newpaths.append(newpath)
except:
pass
"""
for view in views:
for e in escVinc2:
stairid = LinkElementId(e.Id)
newpath = StairsPath.Create(doc, stairid, pathid, view.Id)
newpaths.append(newpath)
TransactionManager.Instance.TransactionTaskDone()
doc.Regenerate()
uidoc.RefreshActiveView()
OUT = newpaths
The stairs from the linked model are collected in another node and connected with the IN[1].
Can anyone help me, please? Thank you very much in advance