Multistory stair components

Hi

I am trying to get all the stairs within a multistory stair. I’ve written a Python script but it is not returning all the individual stairs. I think if a stair has the same floor-to-floor height they must be grouped and only one instance is returned using the GetAllStairsIds command. There looks like there might be another command MultistoryStairsId but I’m not sure if this will do what I need it to do. Any thoughts?

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

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
doc = DocumentManager.Instance.CurrentDBDocument

stairs = IN[0]
#if not isinstance(stairs,list):
stairs = [stairs]

def getRuns(stair):
	runs = []
	stair = UnwrapElement(stair)
	runids = stair.GetAllStairsIds()
	for run in runids:
		runs.append(doc.GetElement(run))
	return runs

OUT = map(getRuns, stairs)
1 Like

Try this. :wink:

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

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

doc = DocumentManager.Instance.CurrentDBDocument

stairs = UnwrapElement(IN[0])
runs=[]
  
  for s in stairs:
	rid=s.GetAllStairsIds()
	for r in rid:
		runs.append(doc.GetElement(r))

OUT = runs
3 Likes

Hi Ewan

I get an error message:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 14, in
TypeError: iteration over non-sequence of type MultistoryStairs

Any idea why?

Try Flatten({list}) in a code block to make it a list.

Hi @Paul_Wintour @Ewan_Opie

How about handling any list structure :sunglasses:

4 Likes

As usual, Nicely done @Kulkul can you share the code? :pray:

Ewan I got your script to work with the Flatten node. But it gives me the same result as my first Python script. This screenshot shows the issue. It is one multistory stair but it only returns two stairs. I’m guessing because L1-L2 is the same as L2-L3 is has been grouped some how. What I am after is the 3 individual stairs returned (from a selected mutistory stair). Thats why I wondering if I needed to use the MultistoryStairsId command as well/ instead.

So I’ve done some more tests and I think I’ve identified the problem but still not sure the solution. If you use all elements of category, it still only returns two stairs. But if you unpin the stairs within the multistory stair, you get three stairs. So is there a way to return all three stairs using Dynamo without unpinning?

Any thoughts?

@Kulkul

@Paul_Wintour Try this For PaulWintor(Mulitple Story).dyn (3.6 KB)

@Ewan_Opie Code is up there :point_up_2:

2 Likes

Sorry @Kulkul

You replied before I had a chance to edit my post.

I just tried you script and it has the same problems. There has been a similar issue but ideally I don’t want to unpin.

@Paul_Wintour I was faster than you :smile:

Let me see if i can sort this out. Cheers!

1 Like

@Paul_Wintour Could you please drop here rvt with some multi story stairs and dyn file?

@Kulkul Revit 2018 file attached. I’m just using your Dynamo script with Dynamo 1.3.

Stair.rvt (1.5 MB)

@Kulkul did you have any luck with this? I’m wondering if I need to use the GetSubelements Method

This page mentions about multi-story stairs:

This element will contain one or more Stairs elements. These can be obtained via GetAllStairsIds and GetStairsOnLevel(ElementId). Stairs elements are either a reference instance which is copied to each level covered by groups of identical stairs instances which share the same level height, or individual Stairs instances which are not connected to a group with the same level height. By default, when adding new levels to the multistory stair, new stairs will be added to the group (shown in the Revit user interface with a ‘Pin’ icon).

For groups of duplicate stairs at different levels, the instances can be found as Subelements of the Stairs element (see GetSubelements .

While @Kulkul is working on a python solution, here is an alternative that may work.
Code from @Einar_Raknes here:


EDIT: Scratch that, still the same issue… @Vikram_Subbaiah seems to have a good one though :grinning:

1 Like

Altering the elevation of any of the associated levels seems to expose multistory stair components.

The code below tries to do so, but it only seems to work on forcing Dynamo to re-execute by changing a value or variable (as demonstrated in the gif below)
multisoryStairs
The base Revit file is the same as the one provided above by @Paul_Wintour (Stair.rvt) and Dynamo is in Automatic Run mode

l = ElementQueries.OfCategory(Category.ByName("Levels"))[1];
a = l.GetParameterValueByName("Elevation");
b = l.SetParameterByName("Elevation",a+0.000);
c = ElementQueries.OfCategory(Category.ByName("Stairs"));

A slight alteration to the above code helps avoid any manual intervention.

Before executing the code…
stairs-1

On executing the code …
stairs-2

l = ElementQueries.OfCategory(Category.ByName("Levels"))[1];
a = l.GetParameterValueByName("Elevation");
b = Transaction.End(l.SetParameterByName("Elevation",a+0.005));
c = l.SetParameterByName("Elevation",Math.Round(a));
d = ElementQueries.OfCategory(Category.ByName("Stairs"));

Thanks @Vikram_Subbaiah but I’m not sure modifying levels is ideal. It opens up a whole can of worms. I was hoping to be able to use the GetSubelements method. It sounds like it should be possible. I got this far. There are no error warnings but its not returning any results.

Any suggestions? @Kulkul @awilliams @Vikram_Subbaiah

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 *

out =
elements = UnwrapElement(IN[0])

for item in elements:
stairs = item.GetSubelements()
out.append(stairs)

OUT = out

Get subelements_2.dyn (4.5 KB)

@Paul_Wintour Think I have cracked it with the GetStairOnLevel method (no unpin) :sunglasses:
Find Multistory Stair Members.dyn (6.8 KB)
ezgif-4-0130bd7219

@Ewan_Opie I can’t enlarge your image but when I run the script it returns the same stair element just repeated. It is only when you unpin one of the stairs, doesn’t the element change to the instance. So I think GetSubelements is still needed

Weird, now that I reopen the example Revit file it does exactly as you describe.
Here is an enlargement of the GIF from above (3 Element IDs)… Im baffled.