Get Sorting Parameters From a Schedule

Hello all,

I am trying to get the parameters used for sorting a schedule. I have gotten close but I cannot figure out how to expose the Autodesk.Revit.DB.SceduleSortGroupField. I am not seeing a method in the API to get at it. API section can be found here:

Any help would be greatly appreciated. Thank you,

import clr

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

scheduleView = UnwrapElement(IN[0])

param = []
for sv in scheduleView:
	definition = sv.Definition
	scheduleParameters = ScheduleDefinition.GetSortGroupFields(definition)
	
	param.append(scheduleParameters)

OUT = param

Does this help in anyway?

import clr

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

scheduleView = UnwrapElement(IN[0])

param = []
for sv in scheduleView:
	definition = sv.Definition
	scheduleParameters = ScheduleDefinition.GetSortGroupFields(definition)
	
	param.append([definition.GetField(i.FieldId).GetName() for i in scheduleParameters])

OUT = param

You can also invoke ParameterId instead of GetName() to work with the parameter. In fact, GetSortGroupFields gives you ScheduleFields used for sorting/grouping.

3 Likes

Thank you so much Hadbirad,

I am going to dig in and figure out what you did but that solved my problem.

1 Like