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!