Closed loekvansteijn closed 5 years ago
Hello Ehsan Iran-Nejad. I created a script to automate these StairPaths. Problem is that it won't create a new StairPath when there is already one created. It will not accept double Stair Paths and it will stops the script. Maybe you can look at it?
Here is the creation part
#create stair path for stair runs
for stairrun in stairruns:
stair = stairrun.GetStairs()
stairid = LinkElementId(stair.Id)
Autodesk.Revit.DB.Architecture.StairsPath.Create(doc, stairid, pathid, doc.ActiveView.Id)
And here the entire script
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
#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
typelist = list()
TransactionManager.Instance.EnsureInTransaction(doc)
#find stairpathtype in project to use for the creation of new ones
collpathtype = FilteredElementCollector(doc)
filtpathtype = ElementCategoryFilter(BuiltInCategory.OST_StairsPaths)
stairpathtypes = collpathtype.WherePasses(filtpathtype).ToElements()
for stairpathtype in stairpathtypes:
istype = stairpathtype.ToString()
if istype == "Autodesk.Revit.DB.Architecture.StairsPathType":
typelist.append(stairpathtype)
stairpathtype = typelist[0]
pathid = stairpathtype.Id
#collect stairruns in active view
collrun = FilteredElementCollector(doc, doc.ActiveView.Id)
filtrun = ElementCategoryFilter(BuiltInCategory.OST_StairsRuns)
stairruns = collrun.WherePasses(filtrun).ToElements()
#create stair path for stair runs
for stairrun in stairruns:
stair = stairrun.GetStairs()
stairid = LinkElementId(stair.Id)
Autodesk.Revit.DB.Architecture.StairsPath.Create(doc, stairid, pathid, doc.ActiveView.Id)
TransactionManager.Instance.TransactionTaskDone()
doc.Regenerate()
uidoc.RefreshActiveView()
OUT = stairruns
@loekvansteijn,
My simple solution would be to put a try, except at the stairpath creation. If it errors out, it will skip that and go to the next one like so:
for stairrun in stairruns:
try:
stair = stairrun.GetStairs()
stairid = LinkElementId(stair.Id)
Autodesk.Revit.DB.Architecture.StairsPath.Create(doc, stairid, pathid, doc.ActiveView.Id)
except:
continue
StairPath is a Autodesk.Revit.DB.NumberSystem
object.
Before creating StairPath, first collect all the DB.NumberSystem
elements in target view and find the associate StairRun to it
doc.GetElement(stair-path.NumberedElementId.HostElementId)
Request to make a function to annotate all the Stairpaths in Active or Selected Views.