# Get fields of a schedule

**URL:** <https://forum.dynamobim.com/t/get-fields-of-a-schedule/92348>\
**Category:** Developers\
**Created:** [July 31, 2023, 8:51am UTC](https://forum.dynamobim.com/t/get-fields-of-a-schedule/92348 "2023-07-31T08:51:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Draxl\_Andreas](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/draxl_andreas/32/145744_2.png) [@Draxl\_Andreas](https://forum.dynamobim.com/u/Draxl_Andreas)\
**Post date:** [July 31, 2023, 8:51am UTC](https://forum.dynamobim.com/t/get-fields-of-a-schedule/92348/1 "2023-07-31T08:51:09Z")

</div>

Hello,

i wanna get all parameters of a schedule (fields) in python:

```auto
#Template 
#DraxlA
#19.07.2023
import clr
import sys 

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

clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *

clr.AddReference('System')
from System.Collections.Generic import List

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

#functions
def tolist(x):
    if hasattr(x,' __iter__'): return x
    else: return [x]

#collector
collector = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Schedules)
all_elements = collector.WhereElementIsNotElementType().ToElements()

#filter 
schedule = [i for i in all_elements if i.Name == "Türliste WGA_AP"]

#Preparing input from dynamo to revit
#element = UnwrapElement(tolist(IN[0]))
params = []

for i in schedule:
	params.append(i.field.GetName())

OUT = params

```

![2023-07-31_11h16_55](https://us1.discourse-cdn.com/flex022/uploads/dynamobim/original/3X/2/5/25361d3875224da406922e46e99db5437195e64c.png)

my code has no error but remains empty! there should be 63 Parameters.

KR

Andreas

---

<div class="post-metadata">

**Author:** ![jacob.small](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/jacob.small/32/161030_2.png) [@jacob.small](https://forum.dynamobim.com/u/jacob.small)\
**Post date:** [July 31, 2023, 11:53am UTC](https://forum.dynamobim.com/t/get-fields-of-a-schedule/92348/2 "2023-07-31T11:53:53Z")

</div>

You have a [ViewSchedule](https://www.revitapidocs.com/2022/0dae24ba-5dcb-9a34-cccc-0cf8cc52bcd3.htm) object in the error.

You want to get the list of fields; note that [there isn’t a ‘Field’ property](https://www.revitapidocs.com/2022/1f953db0-5f60-3363-1d21-df3c9dd2a523.htm) for view schedules, so you have to go on a bit of a hunt for that data.

There is a “Definition” property, the output of which is a [ScheduleDefinition] ([ScheduleDefinition Class](https://www.revitapidocs.com/2022/420696e3-f3ec-1a1d-1205-36a8119d81e5.htm)) object.

The ScheduleDefinition object has a method to [GetFieldOrder()](https://www.revitapidocs.com/2022/3549fb1c-fea6-5b64-a8a9-700337a3907e.htm). The outputs of which are a list of ScheduleFieldId objects, which you can likely use to get the assocaited [ScheduleField](https://www.revitapidocs.com/2022/3d6b0eb5-ed36-278d-a5df-38b6d600e876.htm) object.

The ScheduleField class has a ColumnHeading which I think will return the heading as it would print which may be enough. You can also get the ParameterId if it has one (count, formula, and percentage fields wouldn’t return an id so you’d get Null), which can be used to get the parameter and eventually the name as well.

Not a quick exercise, but it should provide some degree of clarity on how Schedules and Parameters (if you go that deep) are configured in the Revit file.

---

<div class="post-metadata">

**Author:** ![staylor](https://sea2.discourse-cdn.com/flex022/user_avatar/forum.dynamobim.com/staylor/32/94307_2.png) [@staylor](https://forum.dynamobim.com/u/staylor)\
**Post date:** [July 31, 2023, 2:36pm UTC](https://forum.dynamobim.com/t/get-fields-of-a-schedule/92348/3 "2023-07-31T14:36:18Z")

</div>

In line with using ScheduleDefinition as @jacob.small directs. You can use the definition to get the field count and a schedulefield list. Range out the count and use schedulefield getname to list out all the names of the schedulefield list. May not be the most proper way of doing it, but the code below works.

```auto
import clr

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

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager

doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument

sched = UnwrapElement(IN[0])
fldnames=[]
fld=[]

schdef = sched.Definition
fldcnt = ScheduleDefinition.GetFieldCount(schdef)

int = range(fldcnt)

for i in int:
	fld.append(ScheduleDefinition.GetField(schdef,i))

for e in fld:
	fldnames.append(ScheduleField.GetName(e))

OUT = fldnames

```
