error exporting schedule to txt

error exporting schedule to txt

Anonymous
Not applicable
470 Views
1 Reply
Message 1 of 2

error exporting schedule to txt

Anonymous
Not applicable

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).

 

image A.pngimageb.png

 

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-

 

0 Likes
471 Views
1 Reply
Reply (1)
Message 2 of 2

jeremytammik
Autodesk
Autodesk

Dear Nik,

 

I would suggest debugging your code and exploring in more detail what view is causing the failure.

 

You could also check some of the view properties, such as View.CanBePrinted, to skip invalid internal views.

 

My suspicion is that your filtered element collector is returning more views than you really need.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

0 Likes