Message 1 of 1
How to create a ViewSchedule and change Headiling and Center Fields!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I'm trying to create a Schedule and add some Fields automatically using API.
And I'm having a hard time finding how to change the Field Heading, and when I was writing this post to search for some help I found the parameter... (ScheduleField.ColumnHeading)
Long story short I decided to share a code example.
public void CreateViewScheduleWindows(Document doc)
{
Transaction tran = new Transaction(doc);
tran.Start("Create schedule");
ViewSchedule sampleSchedule
= ViewSchedule.CreateSchedule(doc, new
ElementId(BuiltInCategory.OST_Windows));
foreach (ElementId id in
ViewSchedule.GetAvailableParameters(doc, new
ElementId(BuiltInCategory.OST_Windows)))
{
try
{
ScheduleField sf = sampleSchedule.Definition.AddField(
new SchedulableField(ScheduleFieldType.Instance, id));
// Change Heading Field
sf.ColumnHeading = "Field " + sf.FieldIndex;
// Change Alignment Field
sf.HorizontalAlignment = ScheduleHorizontalAlignment.Center;
}
catch (Exception)
{
}
}
tran.Commit();
}
See yaa!