How to duplicate a split schedule

How to duplicate a split schedule

floretti
Advocate Advocate
656 Views
4 Replies
Message 1 of 5

How to duplicate a split schedule

floretti
Advocate
Advocate

Hi all,

 

My research came up fairly empty hence the post. I need to duplicate sheets via the API and I'm struggling to create exact duplicates of schedules that were split in two or more parts and placed on the same sheet.

 

I'm doing some tests on how to achieve that and I can manage to split a schedule using the Split(IList(Double)) however, despite Revit Lookup telling me that my schedule is split, it's shown as one single schedule in the sheet.

 

Part 1

I split the schedule via the UI and collected their segment heights via the API (as I couldn't find that method in Revit Lookup).

var allScheduleSheetInstance = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(ScheduleSheetInstance));
var splitSchedIds = new HashSet<ElementId>();

foreach (ScheduleSheetInstance schedInst in allScheduleSheetInstance)
{
	var viewSched = doc.GetElement(schedInst.ScheduleId) as ViewSchedule;
	
	if (!schedInst.IsTitleblockRevisionSchedule && viewSched.IsSplit() == true)
	{
		splitSchedIds.Add(viewSched.Id);
	}
}

foreach (var splitSchedId in splitSchedIds)
{
	var viewSched = doc.GetElement(splitSchedId) as ViewSchedule;
	int segCount = viewSched.GetSegmentCount();

	for (int i = 0; i < segCount; i++)
	{
		TaskDialog.Show("Title", $"SEGMENT HEIGHT: {viewSched.GetSegmentHeight(i)}");
	}
}

 

Part 2

I then hard coded the heights as a list and passed it to Split() but no success as mentioned before. The schedule is reported as split but it looks the same in the sheet. Any help would be very appreciated.

var allScheduleSheetInstance = new FilteredElementCollector(doc, doc.ActiveView.Id).OfClass(typeof(ScheduleSheetInstance));

foreach (ScheduleSheetInstance schedInst in allScheduleSheetInstance)
{
	var viewSched = doc.GetElement(schedInst.ScheduleId) as ViewSchedule;
	
	if (!schedInst.IsTitleblockRevisionSchedule && viewSched.IsSplit() == false)
	{
		var segHeights = new List<double>(){ 0.25, 0.34 };
		viewSched.Split(segHeights);
	}
}

 

I'm finding the relationship between ScheduleSheetInstance and ViewSchedule very odd. I can have several instances of the same ViewSchedule in different sheets but the IsSplit() method can be found in the ViewSchedule class, not in ScheduleSheetInstance. Also, I can split a schedule in one sheet and leave it as a whole in another but both are reported as split.

0 Likes
657 Views
4 Replies
Replies (4)
Message 2 of 5

floretti
Advocate
Advocate

Come on, forum! Give me something!  😂

Message 3 of 5

V__K
Contributor
Contributor

@floretti 
Were you able to find the solution? I'm facing the same issue.

0 Likes
Message 4 of 5

ctm_mka
Collaborator
Collaborator

i would say first, verify you are getting the correct  ScheduleSheetInstances in your collector. Consider the following image, the same schedule, one split one not:

ctm_mka_0-1730315828527.png

 

0 Likes
Message 5 of 5

ctm_mka
Collaborator
Collaborator

To add to that, i think the issue is you are looking at the ViewSchedule, which is the definition of the schedule. Instead i would focus more on the ScheduleSheetInsance, and duplicate those, you shouldnt need anything other than that.

0 Likes