The elusive Schedule Key ? Where does it live?

ScheduleKeys

 

 

 

 

 

 

 

 

 

Does anyone know IF I can get access to a particular System parameter and it’s associated data , the parameter is called KEY NAME and is created whenever a SCHEDULE KEY type Schedule is created…

I can’t even find this elusive System parameter on exporting the full Revit model to a Database, wondered if Dynamo Could find it ( and it’s accompanying Text , the example above would have a Key Name of F02 for example, and would therefore find Floor 2 beside it )

Thoughts?

 

 

Regards

 

Colin…

 

 

 

 

 

 

 

 

Colin,

I am not sure what you are asking for or rather what the objective here is but Key Schedule Name is not that elusive. You can easily get it by calling this method:

yourSchedule.KeyScheduleParameterName
or you can even set it yourself if you call it like this:
yourSchedule.KeyScheduleParameterName = someName
Now what that will get you is just a name of a parameter but at the end of the day I envision that you want to access the values inside each of the rows of your key schedule and either set a new value or read the existing value. KeyScheduleName is not needed for that and as a matter of fact i found it easier to do without it. I bet some Autodesk Revit API gurus (yeah I am thinking of Jeremy Tammik here :-) ) will disagree with me, but here is my method for getting/setting data in Key Schedule:
#Copyright(c) 2015, Konrad Sobon # @arch_laboratory, http://archi-lab.net

import clr
import sys
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *

Import DocumentManager and TransactionManager

clr.AddReference(“RevitServices”)
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

Import RevitAPI

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

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application

from System.Collections.Generic import *

Import ToDSType(bool) extension method

clr.AddReference(“RevitNodes”)
import Revit
clr.ImportExtensions(Revit.Elements)

pyt_path = r’C:\Program Files (x86)\IronPython 2.7\Lib’
sys.path.append(pyt_path)
import re

#The inputs to this node will be stored as a list in the IN variable.
dataEnteringNode = IN

keySchedule = UnwrapElement(IN[0])
data = IN[1]
inputParams = IN[2]
upper = IN[3]

“Start” the transaction

TransactionManager.Instance.EnsureInTransaction(doc)

tableData = keySchedule.GetTableData()
sectionData = tableData.GetSectionData(SectionType.Body)

keyNames = []
for i in range(1,sectionData.NumberOfRows - 1,1):
keyNames.append(str(int(i)))

allKeys = FilteredElementCollector(doc).WhereElementIsNotElementType()
params = [[] for i in range(len(keyNames))]

for key in allKeys:
try:
if key.get_Parameter(BuiltInParameter.REF_TABLE_ELEM_NAME).AsString() in keyNames and key.OwnerViewId == keySchedule.Id:
indexValue = keyNames.index(key.get_Parameter(BuiltInParameter.REF_TABLE_ELEM_NAME).AsString())
for i in range(0, len(inputParams),1):
params[indexValue].append(key.get_Parameter(str(inputParams[i])))
except:
pass

for i, j in zip(params, data):
for param, value in zip(i,j):
if isinstance(value, str):
valueDecoded = value.decode(‘string_escape’)
else:
valueDecoded = str(value).decode(‘string_escape’)
if upper:
valueDecoded = valueDecoded.upper()
param.Set(valueDecoded)
else:
param.Set(valueDecoded)

“End” the transaction

TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable
OUT = 0


Now of course this blog has impossible formatting for posting code and NO ONE SEEMS TO CARE, so now its your job to figure out indentation in this code snippet. You can thank the awesome webmaster who is managing this blog for the fact that you can’t read the code that users post for you. Please let me know if this works - if you can decode it.

Good luck!

Konrad, many, many thanks for the response, that’s even before I try and ‘unravel’ your code ( with the help of Sol who I work beside…)

Cart before horse, I will explain the reason for the question I guess. I’m creating a Database ( using Revit DB Link ) for my Revit data. Now it is usually extremely good at exporting ALL parameters, system, family and shared, that way I can manipulate the data, in this case, to create Room Data Sheets. What I found was that this particular parameter ( parameter wise it seems fairly unique in Revit as far as I can tell? ) did not export, therefore what I was trying to do is establish if it could be ‘seen’ either through the API/Dynamo etc, that way I could possibly find it within the database in some sort of form.

Make sense?

Weirdly, I discovered it exports fine from a schedule to good ol’ TXT format, but for some reason it fails in Revit DB link. Therefore I have at least found a way to get the data out using one extra step in my workflow.

I have no doubt your level of frustration is through the roof with this blog and how it deals with code, THAT needs to change, it’s fundamental to this type of forum!

Once again, many thanks for the input above. You guys are what keeps Dynamo rolling

 

Colin…

I might be missing something, but wouldn’t this be as easy as fetching the “Floor/Room/etc. Style” parameter like below?

2015-04-10_17-34-50

 

Also I completely agree with Konrad. Visuals and nodes are great but only up to a point. Sometimes, if you want to get to the nitty-gritty, you have to pull up your sleeves and get cracking on some code. Wouldn’t it be nice if we could easily re-use and improve something existing and then just as easily share it back afterwards? Why force people to re-invent the wheel every time? I’m sure integrating one of the existing solutions would be no challenge at all for the web team.

Colin,

I am sure you already know this but just to make sure that you are aware of how the Key Schedules are working “under the hood” and what you really looking at when you see them in UI.

Every line in a key schedule is a legit Revit DB element. That means that in its behavior it is very similar to what a piece of furniture might be. It’s important to understand this because this makes them much different than what data in regular schedules is. That KeyScheduleParameter name is just an identifier for you to be able to get all of those elements for a given Key Schedule. Now, like I said, each row is a unique element and for each row you have a number of columns. Each column is a parameter that you can get/set by selecting the row element and asking it for its parameters. So for example a furniture might have height/width/depth parameters and you can access them only through that furniture. Same is true of key schedule data to get values from particular fields you have to obtain the row element first then its parameter.

Now, I dont use the KeyScheduleParameter to identify what elements belong to what schedule, because i used a different method. you can select all key schedule elements (keys) and see what View owns them. That will give me a schedule id/name and i can filter for all elements belonging to a view. Then you can query each key for its parameters and that will give you all of the values for each row of data in key schedule.

There is a set of nodes for writing/creating key schedules as part of archi-lab package and if you peak under the hood of those python nodes you will see exactly how i access all of the data in key schedules.

Good luck!

1 Like

I am getting an error on line 28, index error out of range: 1

Untitled

 

James,

Does your python node have more than one input? If not, then click the + button to add those. This error should go away if you have all inputs specified as required.

Thanks, yes sorted that - doh!

Now have problem on line 34

AttributeError: ‘Nonetype’ object has no attribute ‘GetTableData’

Untitled

Now, that you added the inputs to your Python node,try feeding something into it? hint: ViewSchedule.

hi Konrad, i try to figure out your Python code, what is BuiltInParameter.GN? well, below captures are my adaption of your exact Python code, seems not updating to my Revit key schedule, well, i just want to find bidirectional way between Excel and Key Schedule, using OOTB nodes only including Python, thanks!
image


image

Hey,

I wonder if you’ve accidentally got a typo? The code above has…

if key.get_Parameter(BuiltInParameter.REF_TABLE_ELEM_NAME).AsString() in keyNames and key.OwnerViewId == keySchedule.Id:

Hope that helps,

Mark

1 Like

thanks Mark, i updated the code, still not working, i must miss something or something wrong w/ that Python, well, not like C#, it’s difficult to troubleshoot Python

edit: works after i use original archi-lab Python

somehow it doesn’t work anymore, same key schedule, same input, Revit key schedule won’t update, i even tried archilab key schedule node


image
i added traceback and below error message:
AttributeError: ‘NoneType’ object has no attribute ‘AsString’
what’s going on? is my input wrong but why it worked before? or just Friday thing!?