CustomExporter Class


A class that allows exporting 3D or 2D views via an export context.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 20.0.0.0 (20.0.0.377)
Since: 2014

Syntax

C#
public class CustomExporter : IDisposable
Visual Basic
Public Class CustomExporter _
	Implements IDisposable
Visual C++
public ref class CustomExporter : IDisposable

Remarks

The Export method of this class triggers standard rendering or exporting process in Revit, but instead of displaying the result on screen or printer, the output is channeled through the given custom context that handles processing of the geometric as well as non-geometric information.

Revit will process the exporting algorithm depending on the type of given context. If an instance of IPhotoRenderContext is used, then Revit will output the model as if executing the Render command, thus only such entities that would be visible in a rendered view will be sent to the context.

Alternatively, if an instance of IModelExportContext is used, Revit will output the model as if exporting it to a CAD format, a process which results outputting also objects that would not appear in a rendered image, such as model curves and text annotations.

For 2D views, an instance of IExportContext2D has to be used. Revit will output the contents of the 2D view as it is displayed on the screen. Export can be modified by setting properties pertaining to 2D views: [!:Autodesk::Revit::DB::IExportContext2D::Export2DGeometricObjectsIncludingPatternLines] , [!:Autodesk::Revit::DB::IExportContext2D::Export2DIncludingAnnotationObjects] . [!:Autodesk::Revit::DB::IExportContext2D::Export2DForceDisplayStyle] . See notes for 2D export in [!:Autodesk::Revit::DB::IExportContextBase] and IExportContext2D .

Examples

Copy C#
/// <summary>
/// This method initiates a custom export process for a given 3D view.
/// </summary>
internal void ExportA3DView(Document document, View a3DView)
{
   // Instantiate an export context - the class that receives the output data during 
   // export process. The context class must implement the IExportContext interface.
   MyExportContext context = new MyExportContext(document);

   // Create an instance of a custom exporter by giving it a document and the context.
   CustomExporter exporter = new CustomExporter(document, context);

   // Optionally set attributes that should apply to the export process. For example:

   // a) Exclude OnFaceBegin and OnFaceEnd method from being invoked in the export
   //    context if data about faces and edges are not relevant to the export.
   //    Excluding face nodes would dramatically speed up the export process.
   //    Note: Excluding faces just excludes the calls, not the actual processing of
   //    face tessellation. Meshes of the faces will still be received by the context.
   exporter.IncludeGeometricObjects = false;

   // b) Set TRUE or FALSE to abort the export process should an error occur
   exporter.ShouldStopOnError = true;

   // Initiate the export process by calling one of Exporter's 'export' method,
   // in this case the one that takes a single 3D view as an argument.
   exporter.Export(a3DView);
}
Copy VB.NET
' <summary>
' This method initiates a custom export process for a given 3D view.
' </summary>
Friend Sub ExportA3DView(document As Document, a3DView As View)
    ' Instantiate an export context - the class that receives the output data during 
    ' export process. The context class must implement the IExportContext interface.
    Dim context As New MyExportContext(document)

    ' Create an instance of a custom exporter by giving it a document and the context.
    Dim exporter As New CustomExporter(document, context)

    ' Optionally set attributes that should apply to the export process. For example:


    ' a) Exclude OnFaceBegin and OnFaceEnd method from being invoked in the export
    '    context if data about faces and edges are not relevant to the export.
    '    Excluding face nodes would dramatically speed up the export process.
    '    Note: Excluding faces just excludes the calls, not the actual processing of
    '    face tessellation. Meshes of the faces will still be received by the context.
    exporter.IncludeGeometricObjects = False

    ' b) Set TRUE or FALSE to abort the export process should an error occur
    exporter.ShouldStopOnError = True

    ' Initiate the export process by calling one of Exporter's 'export' method,
    ' in this case the one that takes a single 3D view as an argument.
    exporter.Export(a3DView)
End Sub

Inheritance Hierarchy

System Object
Autodesk.Revit.DB CustomExporter

See Also