Python help - Get subelements

I wonder if this is possible now that I actual test it in Revit. I only say this because if you try and select the Run and / or the Landing of any stair section within the Multistory stair you are not able to tab through them. You can ONLY tab through them on the first stair. This may mean they are not accessible to that level.

I further tested this by “Snooping” one of the individual stairs in the Multistory stair and when reviewing the ID’s of the stringers and landings, they match the IDs of the same elements for the primary “first” stair. Also, if you try to get “ID of selection” in Revit, it does not produce anything. I think the Subelements are only for that of the first (primary) instance of the Multistory stair.

1 Like

Try this maybe:

@Yna_Db

I used this code but it still is only returning the elements from the single stair. I’m not sure why yours is returning multiple stairs. Are all the floor to floor heights different in your model and that’s why you are getting multiple stairs and hence multiple subelements?

import clr

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

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

str1 = []
str2 = []
str2a = []
str2b = []
str2c = []
str2d = []
str3 = []
mstr = UnwrapElement(IN[0])
stid = mstr.GetAllStairsIds()
for i in stid:
	str1.append(doc.GetElement(i))
for s in str1:
	str2a.append(s.GetAssociatedRailings())
	str2b.append(s.GetStairsLandings())
	str2c.append(s.GetStairsRuns())
	str2d.append(s.GetStairsSupports())
for str in str2b:
	for r in str:
		str3.append(doc.GetElement(r))

OUT = (stid, str1, str3)

Using the GettAllStairIds will only every return the main stair elements from what I can see in Snoop

image

I think the only way is still via subelement, which we can get but then can’t go any further. As @SeanP says, you can’t even tab select it in Revit. So what exactly is a subelement and how can it be used?

Absolutely correct (as a quick workaround, slightly moving some of the levels and placing them back at their initial elevation seems enough to get separated stairs with their associated components…)

1 Like

For further exploration of this, please refer to the Revit API discussion forum thread on multistorey stair subements:

https://forums.autodesk.com/t5/revit-api-forum/multistorey-stair-subements/m-p/8349447

I implemented a test command in C# and reached the same state you descibe above: access to the subelements leads to the individual stair instances within the multistory stair, and the question remains how to process further from there to the sub-subelements, landings, etc.

3 Likes