Edit the schedule column headers with Python

I work on Python script that creates and edits schedules.
I wish to edit the headings of schedule columns - the row that contains the parameter names, below the schedule title. It can be overridden to any other text in UI. As far as I understand, it is the row no. 0 of the Body type of TableSectionData.

I can successfully edit the schedule title, however, when I try to edit the column headers I get the exception ā€œ This operation is forbidden for cells in standard schedule body sections.ā€.

Does it mean that you cannot really edit this row through API, even though you can edit it with UI?

Please see a part of my code (choosing any schedule in the model and trying to override first cell in the column heading).

import clr

from Autodesk.DesignScript.Geometry import *

# Import RevitNodes

import Revit



import Autodesk
from Autodesk.Revit.DB import *

# Import Revit elements
from Revit.Elements import *

# Import DocumentManager
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
from System.Collections.Generic import *

import sys

doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
adoc = doc.ActiveView

schedule = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Schedules).WhereElementIsNotElementType().FirstElement()


tableData = schedule.GetTableData()
tableBody = schedule.GetTableData().GetSectionData(SectionType.Body)
tableBody.SetCellText(0, 0, "MY TEXT")

1 Like

I managed to find solution on my own.
Editing the column headers is possible, but in a different way.
In case anyone would have similar struggle, Iā€™m leaving solution: it worked for me to edit the ColumnHeading property of ScheduleField class, instead of trying to set the cell text.