Message 1 of 7
export a schedule

Not applicable
03-17-2014
01:31 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I want to export schedules to excel. User opens a schedule, clicks the button and saves this schedule to a specified folder.
I use following code:
FilteredElementCollector col = new FilteredElementCollector( doc ).OfClass( typeof( ViewSchedule ) ); ViewScheduleExportOptions opt = new ViewScheduleExportOptions(); SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.Filter = "Excel file(*.xls)|*.xls|CSV file(*.csv)|*.csv|Text file(*.txt)|*.txt"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; foreach (ViewSchedule vs in col) { string path, filename; Autodesk.Revit.DB.View view = uidoc.ActiveView; if (view.ViewType == ViewType.Schedule) { saveFileDialog1.ShowDialog(); path = Path.GetDirectoryName(saveFileDialog1.FileName); filename = uidoc.ActiveView.Name; if (saveFileDialog1.FileName != "") { vs.Export(path, vs.Name + _ext, opt); return Result.Succeeded; } } else { filename = "Choose schedule an active view"; TaskDialog.Show("Active view is", filename); return Result.Failed; } }
There is one mistake. I use foreach, so it returns and saves first schedule in my project.
But I need to save the schedule that is in active view.
How can I acheive this?
Thanks,
Alexander.