Edit the schedule column headers with Python

Hi,
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

clr.AddReference("ProtoGeometry")
from Autodesk.DesignScript.Geometry import *

# Import RevitNodes
clr.AddReference("RevitNodes")

import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitAPI")

clr.AddReference("RevitAPIUI")

import Autodesk
from Autodesk.Revit.DB import *

# Import Revit elements
from Revit.Elements import *

# Import DocumentManager
clr.AddReference("RevitServices")
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()

TransactionManager.Instance.EnsureInTransaction(doc)

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

TransactionManager.Instance.TransactionTaskDone()
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.

https://www.revitapidocs.com/2018.2/3890f745-6f24-f81a-9f8f-d8b47c8e3f94.htm