KeySchedule & Integer Values

Hi All,
Quick qs is it possible to add integer values to a key schedule or am i missing something,all other elements get set however i cant get the integer values applied.


image (01) excel

image (02) Revit populated schedule

image(03) Dynamo screen shot
Cheers Ks

The archilab node converts all incoming values to strings, therefore the element parameter will not update due to the type mismatch with integer

Thanks @Mike.Buttery Do you happen to know of another way or node that could be used to work around that?

Cheers KS

I don’t think there is - you could modify the archilab node python
Crack open the node and update from line 53 to before # "End" the transaction in the second python node
I’ve also done a bit of refactoring so it does not check every element in the document, just the schedule

allKeys = FilteredElementCollector(doc, keySchedule.Id).WhereElementIsNotElementType()
params = [[] for i in range(len(keyNames))]
test = []
for key in allKeys:
	try:
        keyName = key.get_Parameter(BuiltInParameter.REF_TABLE_ELEM_NAME).AsString()
		if keyName in keyNames:
			indexValue = keyNames.index(keyName)
			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')
        elif isinstance(value, int):
            valueDecoded = value  
		else:
			if value == None:
				valueDecoded = " "
			else:
				valueDecoded = str(value).decode('string_escape')
		if upper:
			valueDecoded = valueDecoded.upper()
			param.Set(valueDecoded)
		else:
			param.Set(valueDecoded)

Thanks @Mike.Buttery I believe I copied it across correctly but outcome was still the same.
I’m using Revit 23 could that be the issue?


Cheers KS

The code doesn’t look like it’s updated there should be an elif at line 69 and the filtered element collector should only be for the schedule view like this FilteredElementCollector(doc, keySchedule.Id) on line 53

Make sure to save the script after updating, then save the custom node and finally try your graph

Hi @Mike.Buttery apologies I updated below and get the following warning.

Thanks again for your time.
Cheers KS

Mixed tabs and spaces unfortunately - find and replace tabs with 4 spaces
I’m looking into how to update integers as my code change does not currently work

1 Like

All numbers from an excel sheet are considered Double / float even if they are integers

Change

elif isinstance(value, int):
    valueDecoded = value

To this

elif isinstance(value, (int, float)):
    valueDecoded = int(value)

Note this is for your use case
You would have to check the parameter storage type is ‘Integer’ and then check if all data values are integers and convert (or just convert them with int(n))

1 Like

Awesome thank you @Mike.Buttery this works.

Was trying to paste updated code for future reference , how do i make it look like this
image instead of this


?
Cheers KS

Use the </> code option in menu, surround by single backticks (under esc key) or surround by triple backticks for a block. If you include the code language after the first triple backticks you get syntax highlighting
```python
<code>
```

Thanks updated code below based of your first response from line 53 to before # "End" the transaction in the second python node.
Thanks again for the help.
Cheers KS

`<allKeys = FilteredElementCollector(doc, keySchedule.Id).WhereElementIsNotElementType()
params = [[] for i in range(len(keyNames))]
test = []
for key in allKeys:
    try:
        keyName = key.get_Parameter(BuiltInParameter.REF_TABLE_ELEM_NAME).AsString()
        if keyName in keyNames:
            indexValue = keyNames.index(keyName)
            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')
        elif isinstance(value, (int, float)):
            valueDecoded = int(value) 
        else:
            if value == None:
                valueDecoded = " "
            else:
                valueDecoded = str(value).decode('string_escape')
        if upper:
            valueDecoded = valueDecoded.upper()
            param.Set(valueDecoded)
        else:
            param.Set(valueDecoded)>`