error exporting schedule to txt

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
recently i've created a plugin to export schedule in revit to txt format.
it works well at first using sample model in revit (image A).
the error occur when i try to use other revit model (image B).
i try to find the different between the model that i used. i found out that the sample model that i used does not content any sheet (refer to image A below) but other revit model content sheet (refer image B).
below are the codes that i used to create the plugin.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Diagnostics;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
using Autodesk.Revit.DB;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.ApplicationServices;
using adwin = Autodesk.Windows;
using System.Reflection;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows;
using Excel = Microsoft.Office.Interop.Excel;
namespace xptxt
{
[Transaction(TransactionMode.Automatic)]
public class xptxt : IExternalCommand
{
const string _ext = ".txt";
public Result Execute(ExternalCommandData revit, ref string message, ElementSet elements)
{
try
{
UIApplication rvtUiApp = revit.Application;
Autodesk.Revit.ApplicationServices.Application rvtApp = rvtUiApp.Application;
UIDocument rvtUiDoc = rvtUiApp.ActiveUIDocument;
Autodesk.Revit.DB.Document rvtDoc = rvtUiDoc.Document;
FilteredElementCollector col = new FilteredElementCollector(rvtDoc).OfClass(typeof(ViewSchedule));
ViewScheduleExportOptions opt = new ViewScheduleExportOptions();
string doctitle = rvtDoc.Title;
string _xptfolnem = @"c:\" + doctitle;
foreach (ViewSchedule vs in col)
{
Directory.CreateDirectory(_xptfolnem);
vs.Export(_xptfolnem, vs.Name + _ext, opt);
}
}
catch (IOException ioe)
{
Console.Error.WriteLine(ioe.Message);
}
return Result.Succeeded;
}
}
}
why is the sheet affect the schedule export process?
need help to solve this problem.
Thx in advance.
-nick-