Revit API provides almost all functionalities for exporting, most time exporting is tedious work and API developer can do a lot here. The only problem is to know what the end user real needs. To write export code, it’s relative simple. Let’s use a simple example to demostrate: export current view as a dwf file. The code is:
namespace myRevitApp
{
[Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
[Autodesk.Revit.Attributes.Regeneration(Autodesk.Revit.Attributes.RegenerationOption.Manual)]
public class Class1 : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, Autodesk.Revit.DB.ElementSet elements)
{
Document curDoc = commandData.Application.ActiveUIDocument.Document;
Transaction transaction = new Transaction(curDoc, “Export_To_DWF”);
transaction.Start();
bool exported = false;
ViewSet views = new ViewSet();
views.Insert(curDoc.ActiveView); // add more views if you want to add more.
// if you want other format, just use different export options, such as: DWGExportOptions
// Only keep in mind that different options may contain different properties
// check the setting dialog for manual export, you can know almost all the properties mean
DWFExportOptions options = new DWFExportOptions();
options.ExportObjectData = true;
options.ExportingAreas = false;
options.MergedViews = false;
options.ImageFormat = DWFImageFormat.Lossless;
options.ImageQuality = DWFImageQuality.Default;
exported = curDoc.Export(@”C:\temp”, “test.dwf”, views, options);
transaction.Commit();
if (exported)
return Result.Succeeded;
else
return Result.Failed;
}
}
}
Comments
Leave a comment