Filling a key schedule


Hello,

i stuck somehow, i want just to create my keys based on a excel. i get the values, i get the transaction, but nothing happend, there are 200 key values. it even loads, BUT remains empty.

i want basicly add fields.


CreateKeyScheduleBasedOnExcel.dyn (18.1 KB)

The _data input expects a structure similar to Excel data, consisting of individual line items with values for each column.

You can see some examples in similar posts:

1 Like

@Nick_Boyts

when i write a codeblock i get an error i should use regular brackeds ( of course it is not a dic )

{"SchlĂĽsselname","Kommentare"}; #đź’Ąerror

it mean i can`t create fields i need the fields first at list one parameter to fill.

Correct. You’ll need to have all the appropriate fields added before you write to them. You should be able to add fields to a key schedule just like any other schedule. What issue are you running into there?


@Nick_Boyts , somehow i stuck, even with the created keys.

I think your Archi-Lab might be out of date, as @Konrad_K_Sobon has almost entirely removed all Python nodes from it at this point.

@jacob.small ,

i work with revit 2023,

import clr
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)

#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]

# "Start" the transaction
TransactionManager.Instance.EnsureInTransaction(doc)

test = []
count = []
cellParams = [[] for i in range(len(data))]
if any(isinstance(item, list) for item in data):
	# process list of lists
	for i in data:
		count.append(len(i))
	colCount = max(count)
	colAvailable = len(keySchedule.Definition.GetSchedulableFields())
	if colCount > colAvailable:
		message = "Please add/remove parameters to/from schedule so that they match longest data set."
	else:
		tableData = keySchedule.GetTableData()
		sectionData = tableData.GetSectionData(SectionType.Body)
		if sectionData.NumberOfRows - 2 <= len(data):
			# schedule by default will have 2 rows (A, B, C and Header Names)
			rowsToAdd = (len(data) - sectionData.NumberOfRows) + 2
			for i in range(0, rowsToAdd, 1):
				sectionData.InsertRow(0)
		else:
			# schedule when updating might already have too many rows 
			rowsToDelete = sectionData.NumberOfRows - 2 - len(data)
			for i in reversed(range(sectionData.NumberOfRows - rowsToDelete, sectionData.NumberOfRows, 1)):
				sectionData.RemoveRow(i)

# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()

#Assign your output to the OUT variable
OUT = keySchedule
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))]
test = []
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].extend(key.GetParameters(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:
			if value == None:
				valueDecoded = " "
			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 = keySchedule

And which version of archi-lab? Check manage packages dialog.


@jacob.small

just installed the latest… … need i a olderversion or packages like ironpython2 or 3

Your Key Name parameter should be a string. Try converting those values.

1 Like

Latest version isn’t right. You need the newest version that ends in your Revit release to have the right version of archi-lab. Carefully read the link which I posted a few times now but that should be an archi-lab version that reads something like XXXX.YYY.ZZ23.

1 Like

@jacob.small @Nick_Boyts

i installed a older version. i filled the keys manualy, but i have still problems filling the “regual” parameter. The posts are older(links, revit 2022) so syntex changed. what have i take in mind, lacing? list-depth ? i stuck somehow.

need i to refer to the key name ?, or can i just fill the shared parameter


Unless the input structure is different in older versions, the node isn’t setup for dictionaries. It uses plain lists like your previous post: a list of parameter names and a list of data rows (matching the parameter list).

1 Like