OnInstanceBegin Method


This method marks the beginning of a family instance to be exported

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

Syntax

C#
RenderNodeAction OnInstanceBegin(
	InstanceNode node
)
Visual Basic
Function OnInstanceBegin ( _
	node As InstanceNode _
) As RenderNodeAction
Visual C++
RenderNodeAction OnInstanceBegin(
	InstanceNode^ node
)

Parameters

node
Type: Autodesk.Revit.DB InstanceNode

Return Value

Return RenderNodeAction.Skip if you wish to skip processing this family instance, or return RenderNodeAction.Proceed otherwise.

Examples

Copy C#
/// <summary>
/// This method marks the start of processing a family instance
/// </summary>
public RenderNodeAction OnInstanceBegin(InstanceNode node)
{
   // We can get particular information about the family instance and its type if we need to
   ElementId symbolId = node.GetSymbolId();
   FamilySymbol famSymbol = m_document.GetElement(symbolId) as FamilySymbol;

   // Typically, an export context has to manage a stack of transformation
   // for all nested objects, such as instances, lights, links, etc.
   // A combined transformation needs to be applied to the incoming geometry
   // (providing all geometry is to be flattened in the resultant format.)
   m_TransformationStack.Push(m_TransformationStack.Peek().Multiply(node.GetTransform()));

   // We can either skip this instance or proceed with rendering it.
   return RenderNodeAction.Proceed;
}

/// <summary>
/// This method marks the end of processing a family instance
/// </summary>
public void OnInstanceEnd(InstanceNode node)
{
   // Note: This method is invoked even for instances that were skipped.

   // If we maintain a transformation stack, we need to remove the latest one from it.
   m_TransformationStack.Pop();
}
Copy VB.NET
' <summary>
' This method marks the start of processing a family instance
' </summary>
Public Function OnInstanceBegin(node As InstanceNode) As RenderNodeAction Implements IExportContext.OnInstanceBegin
    ' We can get particular information about the family instance and its type if we need to
    Dim symbolId As ElementId = node.GetSymbolId()
    Dim famSymbol As FamilySymbol = TryCast(m_document.GetElement(symbolId), FamilySymbol)

    ' Typically, an export context has to manage a stack of transformation
    ' for all nested objects, such as instances, lights, links, etc.
    ' A combined transformation needs to be applied to the incoming geometry
    ' (providing all geometry is to be flattened in the resultant format.)
    m_TransformationStack.Push(m_TransformationStack.Peek().Multiply(node.GetTransform()))

    ' We can either skip this instance or proceed with rendering it.
    Return RenderNodeAction.Proceed
End Function

' <summary>
' This method marks the end of processing a family instance
' </summary>
Public Sub OnInstanceEnd(node As InstanceNode) Implements IExportContext.OnInstanceEnd
    ' Note: This method is invoked even for instances that were skipped.


    ' If we maintain a transformation stack, we need to remove the latest one from it.
    m_TransformationStack.Pop()
End Sub

See Also