Erase Schedule Row

I have a key schedule that I would like to be able to clear out all the rows. Is it possible to delete rows of data from a schedule? I would think it should be fairly simple, but I’m not seeing anything.

Aaron

1 Like

Hi @anordstrom,

See if this points you in the right direction.

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

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

doc = DocumentManager.Instance.CurrentDBDocument

schedule = UnwrapElement(IN[0])

TransactionManager.Instance.EnsureInTransaction(doc)
if schedule.ViewType == ViewType.Schedule:
		td = schedule.GetTableData()
		bsd = td.GetSectionData(SectionType.Body)
		for x in range(2,bsd.NumberOfRows): 
			bsd.RemoveRow(x)
TransactionManager.Instance.TransactionTaskDone()

OUT = IN[0]
2 Likes

Thanks! That almost works, but the schedule needs to be formatted to remove all headings and linebreaks before this is run. Is there a way to delete rows in a way that ignores the current formatting of the schedule?