MaterialTakeoff definition.GetFieldOrder() returning empty list

Hi,
I’m trying to use the code from here to get the ScheduleField list from my material takeoff schedule. Since the standard “ScheduleView.Fields” node was returning an empty list.

For a MaterialTakeoff schedule, the line:
ids = definition.GetFieldOrder()
returns an empty list.

I’ve been searching around, but i can’t find the correct method which i should be using for MaterialTakeoff schedules to get the fields.

The code i’m using:

import clr

clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import*

schedule = UnwrapElement(IN[0])
definition = schedule.Definition
ids = definition.GetFieldOrder()
fieldnames = []

def getFields(schedule):
    definition = schedule.Definition

for id in ids:
    param = definition.GetField(id)
    fieldnames.append(param.GetName())

 OUT = fieldnames

Maybe somebody here has an idea? :sweat_smile: