AddInstanceVoidCut Method


Add a cut to an element using the unattached voids inside a cutting instance.

Namespace: Autodesk.Revit.DB
Assembly: RevitAPI (in RevitAPI.dll) Version: 17.0.0.0 (17.0.1090.0)
Since: 2011

Syntax

C#
public static void AddInstanceVoidCut(
	Document document,
	Element element,
	Element cuttingInstance
)
Visual Basic
Public Shared Sub AddInstanceVoidCut ( _
	document As Document, _
	element As Element, _
	cuttingInstance As Element _
)
Visual C++
public:
static void AddInstanceVoidCut(
	Document^ document, 
	Element^ element, 
	Element^ cuttingInstance
)

Parameters

document
Type: Autodesk.Revit.DB Document
The document containing the two elements
element
Type: Autodesk.Revit.DB Element
The element to be cut
cuttingInstance
Type: Autodesk.Revit.DB Element
The cutting family instance

Examples

Copy C#
// Cut a beam with 3 instances of a void-cutting family
// The Family Parameter "Cut with Voids When Loaded" must be true for the cutting family
void CutBeamWithFamilyVoid(Autodesk.Revit.DB.Document doc, FamilyInstance beam, FamilySymbol cuttingSymbol)
{
    LocationCurve lc = beam.Location as LocationCurve;
    Curve beamCurve = lc.Curve;

    for (int i = 1; i <= 3; i++)
    {
        XYZ beamLocation = beamCurve.Evaluate(i * 0.25, true); // position on the beam for this cutting instance
        beamLocation = beamLocation - XYZ.BasisZ; // adjust for top-aligned curve

        Level level = doc.GetElement(beam.LevelId) as Level;
        FamilyInstance cuttingInstance = doc.Create.NewFamilyInstance(beamLocation, cuttingSymbol, level, StructuralType.NonStructural);
        InstanceVoidCutUtils.AddInstanceVoidCut(doc, beam, cuttingInstance);
    }
}
Copy VB.NET
' Cut a beam with 3 instances of a void-cutting family
' The Family Parameter "Cut with Voids When Loaded" must be true for the cutting family
Private Sub CutBeamWithFamilyVoid(doc As Autodesk.Revit.DB.Document, beam As FamilyInstance, cuttingSymbol As FamilySymbol)
    Dim lc As LocationCurve = TryCast(beam.Location, LocationCurve)
    Dim beamCurve As Curve = lc.Curve

    For i As Integer = 1 To 3
        Dim beamLocation As XYZ = beamCurve.Evaluate(i * 0.25, True)
        ' position on the beam for this cutting instance
        beamLocation = beamLocation - XYZ.BasisZ
        ' adjust for top-aligned curve
        Dim level As Level = TryCast(doc.GetElement(beam.LevelId), Level)
        Dim cuttingInstance As FamilyInstance = doc.Create.NewFamilyInstance(beamLocation, cuttingSymbol, level, StructuralType.NonStructural)
        InstanceVoidCutUtils.AddInstanceVoidCut(doc, beam, cuttingInstance)
    Next
End Sub

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentException The element cannot be cut with a void instance. -or- The element is not a family instance with an unattached void that can cut.
Autodesk.Revit.Exceptions ArgumentNullException A non-optional argument was NULL
Autodesk.Revit.Exceptions ForbiddenForDynamicUpdateException This method may not be called during dynamic update.
Autodesk.Revit.Exceptions InvalidOperationException Failed to cut element with the instances

See Also