Start Method


This method is called at the very start of the export process, still before the first entity of the model was send out.

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

Syntax

C#
bool Start()
Visual Basic
Function Start As Boolean
Visual C++
bool Start()

Return Value

Return True if you are ready to proceed with processing the export.

Examples

Copy C#
// A context would typically maintain a variable for the document being exported
private Document m_document = null;

// Some contexts may find it useful to have a flag indicating
// whether or not the process should be canceled (see Is
private bool m_cancelled = false;

// Typically, an export context has to manage a stack of transformation
// for all nested objects, such as instances, lights, links, etc.
private Stack<Transform> m_TransformationStack = new Stack<Transform>();

/// <summary>
/// Assuming that instance variables gets initiated in the context's constructor
/// </summary>
/// <param name="document"></param>
public MyExportContext(Document document)
{
   m_document = document;
   m_TransformationStack.Push(Transform.Identity);
}

/// <summary>
/// This method is the starting point of the export process.
/// </summary>
/// <remarks>
/// The method is called only once and is typically used to prepare
/// the context object, e.g. crate or open the output files,
/// or establish a connection to an on-line renderer, etc.
/// </remarks>
/// <returns>
/// Return true if the export process it good to start.
/// </returns>
public bool Start()
{
   return true;
}

/// <summary>
/// This method establishes the final point of the export process.
/// </summary>
/// <remarks>
/// Resources (such as files, pipes, threads, etc.) used by the context
/// should be properly released/closed inside this method.
/// </remarks>
public void Finish()
{
}

/// <summary>
/// This method is invoked many times during the export process.
/// </summary>
/// <remarks>
/// Depending on internal condition of the context, it can be decided
/// whether the export is to be immediately canceled or not.
/// </remarks>
public bool IsCanceled()
{
   return m_cancelled;
}
Copy VB.NET
' A context would typically maintain a variable for the document being exported
Private m_document As Document = Nothing

' Some contexts may find it useful to have a flag indicating
' whether or not the process should be canceled (see Is
Private m_cancelled As Boolean = False

' Typically, an export context has to manage a stack of transformation
' for all nested objects, such as instances, lights, links, etc.
Private m_TransformationStack As New Stack(Of Transform)()

' <summary>
' Assuming that instance variables gets initiated in the context's constructor
' </summary>
' <param name="document"></param>
Public Sub New(document As Document)
    m_document = document
    m_TransformationStack.Push(Transform.Identity)
End Sub

' <summary>
' This method is the starting point of the export process.
' </summary>
' <remarks>
' The method is called only once and is typically used to prepare
' the context object, e.g. crate or open the output files,
' or establish a connection to an on-line renderer, etc.
' </remarks>
' <returns>
' Return true if the export process it good to start.
' </returns>
Public Function Start() As Boolean Implements IExportContext.Start
    Return True
End Function

' <summary>
' This method establishes the final point of the export process.
' </summary>
' <remarks>
' Resources (such as files, pipes, threads, etc.) used by the context
' should be properly released/closed inside this method.
' </remarks>
Public Sub Finish() Implements IExportContext.Finish
End Sub

' <summary>
' This method is invoked many times during the export process.
' </summary>
' <remarks>
' Depending on internal condition of the context, it can be decided
' whether the export is to be immediately canceled or not.
' </remarks>
Public Function IsCanceled() As Boolean Implements IExportContext.IsCanceled
    Return m_cancelled
End Function

See Also