Revit 2025 API
IExport |
This method marks the beginning of an element to be exported.
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
RenderNodeAction OnElementBegin( ElementId elementId )
Function OnElementBegin ( elementId As ElementId ) As RenderNodeAction
RenderNodeAction OnElementBegin( ElementId^ elementId )
abstract OnElementBegin : elementId : ElementId -> RenderNodeAction
Parameters
- elementId ElementId
- The Id of the element that is about to be processed.
Return Value
RenderNodeActionReturn RenderNodeAction.Skip if you wish to skip exporting this element, or return RenderNodeAction.Proceed otherwise.

This method is never called for 2D export (see cref="Autodesk::Revit::DB::IExportContext2D").

/// <summary> /// Often it is found beneficial to keep a stack of th element(s) /// currently being processed, so it can be refer to it from other /// methods of the export context. /// </summary> Stack<ElementId> m_elementStack = new Stack<ElementId>(); ElementId CurrentElementId() { return (m_elementStack.Count > 0) ? m_elementStack.Peek() : ElementId.InvalidElementId; } /// <summary> /// Method that indicates the start of processing an element. /// </summary> public RenderNodeAction OnElementBegin(ElementId elementId) { // We may find it useful to remember this element's Id. // So we can refer to it in methods invoked during the // export process of this element m_elementStack.Push(elementId); // We can use the element's Id to find out more about the element being processed. // For example, we can test if the element is a wall; if it is, we can get more // information about the wall and then we can proceed with the export, which will // continue with processing geometry of the element. Elements that are not wall // will be skipped. Wall theWall = m_document.GetElement(elementId) as Wall; if (theWall != null) { double wallVolume = theWall.get_Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED).AsDouble(); return RenderNodeAction.Proceed; } else { return RenderNodeAction.Skip; } } /// <summary> /// Method that indicates the end of processing an element /// </summary> public void OnElementEnd(ElementId elementId) { // Note: this method is invoked even for elements that were skipped. m_elementStack.Pop(); }
' <summary> ' Often it is found beneficial to keep a stack of th element(s) ' currently being processed, so it can be refer to it from other ' methods of the export context. ' </summary> Private m_elementStack As New Stack(Of ElementId)() Private Function CurrentElementId() As ElementId Return If((m_elementStack.Count > 0), m_elementStack.Peek(), ElementId.InvalidElementId) End Function ' <summary> ' Method that indicates the start of processing an element. ' </summary> Public Function OnElementBegin(elementId As ElementId) As RenderNodeAction Implements IExportContext.OnElementBegin ' We may find it useful to remember this element's Id. ' So we can refer to it in methods invoked during the ' export process of this element m_elementStack.Push(elementId) ' We can use the element's Id to find out more about the element being processed. ' For example, we can test if the element is a wall; if it is, we can get more ' information about the wall and then we can proceed with the export, which will ' continue with processing geometry of the element. Elements that are not wall ' will be skipped. Dim theWall As Wall = TryCast(m_document.GetElement(elementId), Wall) If theWall IsNot Nothing Then Dim wallVolume As Double = theWall.Parameter(BuiltInParameter.HOST_VOLUME_COMPUTED).AsDouble() Return RenderNodeAction.Proceed Else Return RenderNodeAction.Skip End If End Function ' <summary> ' Method that indicates the end of processing an element ' </summary> Public Sub OnElementEnd(elementId As ElementId) Implements IExportContext.OnElementEnd ' Note: this method is invoked even for elements that were skipped. m_elementStack.Pop() End Sub
No code example is currently available or this language may not be supported.
No code example is currently available or this language may not be supported.
See Also