InstanceVoidCutUtilsAddInstanceVoidCut 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: 25.0.0.0 (25.0.0.0)
Syntax
public static void AddInstanceVoidCut(
	Document document,
	Element element,
	Element cuttingInstance
)

Parameters

document  Document
The document containing the two elements
element  Element
The element to be cut
cuttingInstance  Element
The cutting family instance
Exceptions
ExceptionCondition
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.
ArgumentNullException A non-optional argument was null
ForbiddenForDynamicUpdateException This method may not be called during dynamic update.
InvalidOperationException Failed to cut element with the instances
Example
// 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);
    }
}
See Also