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) )
else:
dataListColumn.Add( TableView.GetCell(schedule, SectionType.Body, row, column) )
dataListRow.Add( dataListColumn );
# "End" the transaction
TransactionManager.Instance.TransactionTaskDone()
OUT = dataListRow
All data with the default python script is string data:
Hello,
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
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference('RevitServices')
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:
paraSchNames.append(field.GetName())
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)
temp.append(value)
#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)
temp.append(value)
out.append(temp)
OUT = out
else:
OUT = "Wrong View"
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 tried to execute your code and I couldnât the error message was ââScheduleViewâ object has no attribute âGetTableData()ââ, is this node named âSchedule Viewsâ just the âRevit>Selection>Viewsâ node renamed or is it from some package? It would be very useful to me, specially if there is another function to set the data because Iâm trying to modify revit sheets using Dynamo. Thank you in advance.