Hello everyone,
I need help getting the nested view schedules that were split from a schedule. I’ll go over the context, problem, code and finally methods I have tried.
Context:
I have a number of sheets and each one has a single schedule by the name of “CUT LIST”. These schedules are usually too long so I typically just manually split it in half using “Split Schedule Table.” This lays each half of the schedule side by side on the sheet and displays like this in the Project Browser:
S1 - CUT LIST
├── S1 - CUT LIST 1/2
└── S1 - CUT LIST 2/2
I thought it would be useful to write a script that essentially takes a selection of sheets and programmatically splits the schedule in half.
Problem:
After using the Split
method I expected it to automatically place or rather replace the original whole schedule with its halves. The method successfully split the schedule in two halves but that’s about it. I then thought I could achieve the rest as such:
- Delete the whole schedule instance from the sheet
- Get the two split halves
- Place the halves onto the sheet.
The problem lies in getting the two nested halves. The print statement simply outputs “1”, which tells me that split_schedules
is simply retrieving the top level schedule and not the nested halves.
Code:
schedules = [get_cut_list(s) for s in sheets]
if schedules:
all_schedules = FilteredElementCollector(doc).OfClass(ViewSchedule).ToElements()
for schedule_instance in schedules:
schedule_name = schedule_instance.Name
schedule_view = doc.GetElement(schedule_instance.ScheduleId)
with revit.Transaction('Split Cut List', doc):
schedule_view.Split(2)
with revit.Transaction('Delete Cut List Instance', doc):
doc.Delete(schedule_instance.Id)
split_schedules = [sch for sch in all_schedules if schedule_name in sch.Name]
print(len(split_schedules))
# Place split schedules on sheet...
Methods I have tried:
- GetDependentViewIds
- GetDependentElements
- GetSubElements
Is there a method to retrieve nested split schedules that I am missing or perhaps another workaround?