IExportContext.OnElementBegin
Method
Description:
This method marks the beginning of an element to be exported.
This method marks the beginning of an element to be exported.
Remarks:
This method is never called for 2D export (see cref="Autodesk::Revit::DB::IExportContext2D").
This method is never called for 2D export (see cref="Autodesk::Revit::DB::IExportContext2D").
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();
}
Parameters
Parameter | Type | Description |
---|---|---|
elementId | ElementId | The Id of the element that is about to be processed. |
Return Value
Type | Description |
---|---|
RenderNodeAction | Return RenderNodeAction.Skip if you wish to skip exporting this element, or return RenderNodeAction.Proceed otherwise. |