Revit 2017.1 API |
IExportContext..::..OnElementBegin Method |
IExportContext Interface Example See Also |
This method marks the beginning of an element to be exported
Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since:
2014
Syntax
C# |
---|
RenderNodeAction OnElementBegin( ElementId elementId ) |
Visual Basic |
---|
Function OnElementBegin ( _ elementId As ElementId _ ) As RenderNodeAction |
Visual C++ |
---|
RenderNodeAction OnElementBegin( ElementId^ elementId ) |
Parameters
- elementId
- Type: Autodesk.Revit.DB..::..ElementId
The Id of the element that is about to be processed
Return Value
Return RenderNodeAction.Skip if you wish to skip exporting this element, or return RenderNodeAction.Proceed otherwise.
Examples

/// <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