Stair riser number system

Does anyone know if it possible to create a new number system instance to a stair run? It looks like it should be possible with Python:

http://www.revitapidocs.com/2018.1/e56310b2-3357-dadf-7f42-2ccac6045e70.htm

@Kulkul since you’re on a roll! Any thoughts on this?

Trying to create a number system on a stair run for both plan and section. I believe the create method is: Create(Document, ElementId, LinkElementId, Reference). I’ve got the stair path:

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)


out = []
elements = UnwrapElement(IN[0])


for item in elements:
	stairpath = item.GetStairsPath()
	out.append(stairpath)	


OUT = out 

And I can get the location curve:

import clr
import math

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)


trappen = UnwrapElement(IN[0])
curves = list()


for trap in trappen:
	for item in trap:	
		try:
			loc = item.Location
			loc.ToString() == 'Autodesk.Revit.DB.LocationCurve'
			curves.append(loc.Curve.ToProtoType())
		except:
			curves.append(item.ToProtoType())
	

OUT = curves

Not sure of the next step though. I’m guessing though that you only need a location curve if you are creating a number system in plan view?

I managed to get this far but I’m a Python noobie. Any suggestions? @Kulkul @Vikram_Subbaiah @awilliams

numberSystem.dyn (8.7 KB)

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager

out = []
doc = DocumentManager.Instance.CurrentDBDocument
stairnum = []
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
ref = UnwrapElement(IN[2])


for item in elements:
	stairnum = item.NumberSystem(doc, view, item, ref)
	out.append(stairnum)	

OUT = out

A few things I see that need to be fixed here - you’re calling the Create method incorrectly (it is not an attribute of StairRuns), the argument is for the view Id (not the view), and you’re also feeding a list (ref) where it should be singletons for each NumberSystem being created. Try modifying your code to this and see where it gets you:

for item,ref in zip(elements,refs):
	stairnum = Autodesk.Revit.DB.NumberSystem.Create(doc, view.Id, item, ref)

Note you will need to change ref = UnwrapElement(IN[2]) to refs = UnwrapElement(IN[2]) and add import Autodesk to your imports

Hi @awilliams

I tried amending the Python script. Not sure what you mean by add import Autodesk. Although clearly it’s not right as I’m getting ‘Autodesk not defined’ on line 25.

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager


out = []
doc = DocumentManager.Instance.CurrentDBDocument
stairnum = []
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
refs = UnwrapElement(IN[2])


for item,ref in zip(elements,refs):
	stairnum = Autodesk.Revit.DB.NumberSystem.Create(doc, view.Id, item, ref)
	out.append(stairnum)	

OUT = out

You need to add import Autodeskwith your imports like

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
import Autodesk

Hi @awilliams. I’m getting this error message. I’m not sure of the difference between LinkElementId and ElementId. Thoughts?

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 26, in
TypeError: expected LinkElementId, got ElementId

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
import Autodesk


out = []
doc = DocumentManager.Instance.CurrentDBDocument
stairnum = []
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
refs = UnwrapElement(IN[2])


for item,ref in zip(elements,refs):
	stairnum = Autodesk.Revit.DB.NumberSystem.Create(doc, view.Id, item.Id, ref)
	out.append(stairnum)	

OUT = out

numberSystem.dyn (5.3 KB)

The way I’d describe LinkElementId here (to the best of my knowledge) is that you need to have the ElementId of the StairRun represented as a host for the number system. To construct it in your code you’d simply modify item.Id to be LinkElementId(item.Id) Give this a try:

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
import Autodesk


out = []
doc = DocumentManager.Instance.CurrentDBDocument
stairnum = []
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
refs = UnwrapElement(IN[2])

for item,ref in zip(elements,refs):
	stairnum = Autodesk.Revit.DB.NumberSystem.Create(doc, view.Id, LinkElementId(item.Id), ref)
	out.append(stairnum)

OUT = out

Apologies in advance that I haven’t tested this so let me know if this works. You may or may not need to start and end a transaction.

PS If I were you I would turn your “Number system reference” script (the output you are using for IN[2]) into a definition within the Number System creation Python script

Hi @awilliams

I managed to get it to work on a single view but using a more complicated list structure over multiple views I am getting an error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 26, in
AttributeError: ‘List[object]’ object has no attribute ‘Id’

import clr
import math
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Architecture import *

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
import Autodesk


out = []
doc = DocumentManager.Instance.CurrentDBDocument
stairnum = []
elements = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
refs = UnwrapElement(IN[2])


for item,ref in zip(elements,refs):
	stairnum = Autodesk.Revit.DB.NumberSystem.Create(doc, view.Id, LinkElementId(item.Id), ref)
	out.append(stairnum)	

OUT = out