Schedule in Revit to Dynamo Data - Maintain Data Types

I am trying to expand on the python script that was posted in this post:

My Revit schedule looks like the following:

The first column will be text data and the following information will be dimensional data.
The problem that I have is all data that is called via the getcelltext() function is purely that, only text. Is there a function that can pull numerical data from a cell in the Revit API? From what I could tell there was not. I tried the obvious getcellvalue() type functions, but to no avail.

My changed code looks like the following:

table = schedule.GetTableData().GetSectionData(SectionType.Body)
nRows = table.NumberOfRows
nColumns = table.NumberOfColumns

#Collect all of data from the schedule
dataListRow = []
for row in range(nRows): #Iterate through the rows. The second row is always a blank space
	dataListColumn = []
	for column in range(nColumns): #Iterate through the columns
		if column == 0:
			dataListColumn.Add( TableView.GetCellText(schedule, SectionType.Body, row, column) )
			dataListColumn.Add( TableView.GetCell(schedule, SectionType.Body, row, column) )
	dataListRow.Add( dataListColumn );

# "End" the transaction

OUT = dataListRow

All data with the default python script is string data:

Any easy workarounds to get numerical data from a cell?

to my knowledge it is not possible to obtain the numerical data of the parameters with classes TableView and TableSectionData
If your fields of Schedule are Parameters you can try this method

import clr
from Autodesk.DesignScript.Geometry import *

import Autodesk
from Autodesk.Revit.DB import *

import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument

def convert_Value(paraL):
	if paraL.StorageType == StorageType.Double : 
		value = paraL.AsDouble()
		unitType = paraL.Definition.UnitType
		formatOption = doc.GetUnits().GetFormatOptions(unitType)
		displayUnit = formatOption.DisplayUnits
		convert =  UnitUtils.ConvertFromInternalUnits(value,displayUnit)
		return convert
	elif paraL.StorageType == StorageType.String : 	
		value = paraL.AsString()
		if value is None:
			value = paraL.AsValueString()
		return value
	elif paraL.StorageType == StorageType.Integer: 	
		value = paraL.AsInteger()
		return value	
	elif paraL.StorageType == StorageType.ElementId: 	
		valueId = paraL.AsElementId()
		return doc.GetElement(valueId)

scheduleView = UnwrapElement(IN[0])

if scheduleView.ViewType == ViewType.Schedule:	
	collinview = FilteredElementCollector(doc, scheduleView.Id).OfClass(FamilyInstance).WhereElementIsNotElementType().ToElements()
	definition = scheduleView.Definition
	ids = definition.GetFieldOrder()
	paraSchNames = []
	out = []
	for id in ids:
		field = definition.GetField(id)
		if field.FieldType  == ScheduleFieldType.Instance or field.FieldType  == ScheduleFieldType.ElementType:
	for elem in collinview:
		temp = []
		elemType = doc.GetElement(elem.GetTypeId())
		for paraSchName in paraSchNames:
			value = None
			paraelem = elem.LookupParameter(paraSchName)
			if paraelem is not None:	
				value = convert_Value(paraelem)
			#if value is None check if it's a Parameter Type	
			if 	value is None:
				paraelemT = elemType.LookupParameter(paraSchName)
				if paraelemT is not None:	
					value = convert_Value(paraelemT)

	OUT = out
	OUT = "Wrong View"

the order of the output list of the Python node is not necessarily the same as the Schedule (if you apply sorting in properties of Schedule)

Thanks @c.poupin, but unfortunately, the data in my schedule is not a parameter. I am trying to use the data in my schedule to write information to parameters… kinda of silly I know.

I broke down and wrote some code to convert feet and inches to decimal feet based on string data.

1 Like