Get a nested parameter value


#1

Anyone know if it’s possible to get the value of a stairs “Actual Run Width”? It’s nested in the run of a component stair. Thanks


#2

I believe you’ll have to use Python and the GetStairsRuns() method to pull the stair run element from your stair, and get the parameter value from that


#3

Lol. Thanks for the relpy! I’m fairly new to Dynamo. Not sure I’m ready for Python.


#4

Here is a script for it:

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.GetStairsRuns()
	for run in runids:
		runs.append(doc.GetElement(run))
	return runs

OUT = map(getRuns, stairs)

Paste this into a Python script node and connect your stair (or list of stairs) to it and it will give you its respective stair runs, which you can query for the run width with GetParameterValueByName.

Let me know if this works for you :slight_smile:


#5

Wow! Thanks! I’ll try it on Monday.


#6

Worked perfectly. Thank you!


#7

Hi, Is it possible to edit the Python script to get the x,y,z of the run? I can do the research (you’ve done enough), I just want to know if it’s possible before I spend the time. I’m having problems inserting a tag since the stairs themselves don’t have an insertion point. Thanks Again!


#8

@BBDCW Hmm you mean the location? The OOTB node Tag.ByElement should work without a location


#9

Hi Amy and thanks.

When I was working on the door version I was getting errors using the Tag.ByElementAndOffset as well as the Tag.ByElement. No one could figure it out so I went with Create Annotation Tag and that worked. However when I tweaked it for the stairs it wouldn’t work.

Here’s the original error I was getting on the door version:


#10

PS I was trying to get a point to place the tag after it calculated some other values and set the parameters of the element being tagged. Element.GetLocation worked for the door version but not the stairs.

The image shows the stair version that uses the Create Annotation Tag.

Stairs


#11

Ah yeah I wouldn’t have expected GetLocation to return a point because the stair runs don’t have an insertion point, they’re more line/sketch based. One possible idea would be to get the solid geometry with Element.Geometry and use Solid.Centroid to get a point and remove the z value

PS your code block that reads "True" and "False" needs to be true and false to be proper booleans and not strings


#12

As usual nothing but excellent advice from you. Solid.Centroid looks promising. Working on losing the Z now. Thanks for the boolean advice.


#13

Got it working. Element.Geometry, Soild.Centroid and changing Z to 0 worked. Thanks!