OnInstanceBegin Method


IExport Context On Instance Begin Method

This method marks the start of processing of an instance node (e.g. a family instance).

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 25.0.0.0 (25.0.0.0)
Syntax
RenderNodeAction OnInstanceBegin(
	InstanceNode node
)

Parameters

node InstanceNode

Return Value

RenderNodeAction
Return RenderNodeAction.Skip if you wish to skip processing this family instance, or return RenderNodeAction.Proceed otherwise.
Example
/// <summary>
/// This method marks the start of processing of an Instance node (e.g. 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.GetSymbolGeometryId().SymbolId;
   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 of an Instance Node (e.g. 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();
}
See Also
ArchiLabs Desktop

Put AI to work inside Revit.

Give Desktop your instructions and project files to build Revit families, update model elements, and create views and schedules. Works directly in Revit and AutoCAD.

Explore Desktop →