NewSweptBlend Method (Boolean, Curve, SketchPlane, SweepProfile, SweepProfile)


Add a new swept blend into the family document, using a curve as the path.

Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 2015.0.0.0 (2015.0.0.0)

Syntax

C#
public SweptBlend NewSweptBlend(
	bool isSolid,
	Curve path,
	SketchPlane pathPlane,
	SweepProfile bottomProfile,
	SweepProfile topProfile
)
Visual Basic
Public Function NewSweptBlend ( _
	isSolid As Boolean, _
	path As Curve, _
	pathPlane As SketchPlane, _
	bottomProfile As SweepProfile, _
	topProfile As SweepProfile _
) As SweptBlend
Visual C++
public:
SweptBlend^ NewSweptBlend(
	bool isSolid, 
	Curve^ path, 
	SketchPlane^ pathPlane, 
	SweepProfile^ bottomProfile, 
	SweepProfile^ topProfile
)

Parameters

isSolid
Type: System Boolean
Indicates if the swept blend is Solid or Void.
path
Type: Autodesk.Revit.DB Curve
The path of the swept blend. The path should be a single curve. Or the path can be a single sketched curve, and the curve is not required to reference existing geometry.
pathPlane
Type: Autodesk.Revit.DB SketchPlane
The sketch plane for the path. Use this when you want to create a 2D path that resides on an existing planar face. Optional, can be a null reference ( Nothing in Visual Basic) for a path curve obtained from geometry or for 2D paths where the path should not reference an existing edge.
bottomProfile
Type: Autodesk.Revit.DB SweepProfile
The bottom profile of the newly created Swept blend. It should consist of only one curve loop. The profile must lie in the XY plane, and it will be transformed to the profile plane automatically.
topProfile
Type: Autodesk.Revit.DB SweepProfile
The top profile of the newly created Swept blend. It should consist of only one curve loop. The profile must lie in the XY plane, and it will be transformed to the profile plane automatically.

Return Value

If creation was successful the new Swept blend is returned, otherwise an exception with failure information will be thrown.

Remarks

This method creates a swept blend in a family document. The swept blend will trace from bottom profile to the top along the path. Revit will determine an appropriate default mapping for the vertices of the two profiles. If the input profile is to be a cyclic profile (curve or ellipse) it must be split into at least two segments, so that Revit can find vertices to use for mapping the swept blend.

Examples

Copy C#
private SweptBlend CreateSweptBlend(Autodesk.Revit.DB.Document document, SketchPlane sketchPlane)
{
    SweptBlend newSweptBlend = null;

    // make sure we have a family document
    if (true == document.IsFamilyDocument)
    {
        // Create top and bottom profiles and path curve
        XYZ pnt1 = new XYZ(0, 0, 0);
        XYZ pnt2 = new XYZ(1, 0, 0);
        XYZ pnt3 = new XYZ(1, 1, 0);
        XYZ pnt4 = new XYZ(0, 1, 0);
        XYZ pnt5 = new XYZ(0, 0, 1);

        CurveArrArray arrarr1 = new CurveArrArray();
        CurveArray arr1 = new CurveArray();
        arr1.Append(Line.CreateBound(pnt1, pnt2));
        arr1.Append(Line.CreateBound(pnt2, pnt3));
        arr1.Append(Line.CreateBound(pnt3, pnt4));
        arr1.Append(Line.CreateBound(pnt4, pnt1));
        arrarr1.Append(arr1);

        XYZ pnt6 = new XYZ(0.5, 0, 0);
        XYZ pnt7 = new XYZ(1, 0.5, 0);
        XYZ pnt8 = new XYZ(0.5, 1, 0);
        XYZ pnt9 = new XYZ(0, 0.5, 0);
        CurveArrArray arrarr2 = new CurveArrArray();
        CurveArray arr2 = new CurveArray();
        arr2.Append(Line.CreateBound(pnt6, pnt7));
        arr2.Append(Line.CreateBound(pnt7, pnt8));
        arr2.Append(Line.CreateBound(pnt8, pnt9));
        arr2.Append(Line.CreateBound(pnt9, pnt6));
        arrarr2.Append(arr2);

        SweepProfile bottomProfile = document.Application.Create.NewCurveLoopsProfile(arrarr1);
        SweepProfile topProfile = document.Application.Create.NewCurveLoopsProfile(arrarr2);

        XYZ pnt10 = new XYZ(5, 0, 0);
        XYZ pnt11 = new XYZ(0, 20, 0);
        Curve curve = Line.CreateBound(pnt10, pnt11);

        // here create rectangular swept blend
        newSweptBlend = document.FamilyCreate.NewSweptBlend(true, curve, sketchPlane, bottomProfile, topProfile);
        if (null != newSweptBlend)
        {
            // move to proper place
            XYZ transPoint1 = new XYZ(11, 32, 0);
            ElementTransformUtils.MoveElement(document, newSweptBlend.Id, transPoint1);
        }
        else
        {
            throw new Exception("Failed to create new SweptBlend.");
        }
    }
    else
    {
        throw new Exception("Please open a Family document before invoking this command.");
    }
    return newSweptBlend;
}
Copy VB.NET
Private Function CreateSweptBlend(document As Autodesk.Revit.DB.Document, sketchPlane As SketchPlane) As SweptBlend
    Dim newSweptBlend As SweptBlend = Nothing

    ' make sure we have a family document
    If True = document.IsFamilyDocument Then
        ' Create top and bottom profiles and path curve
        Dim pnt1 As New XYZ(0, 0, 0)
        Dim pnt2 As New XYZ(1, 0, 0)
        Dim pnt3 As New XYZ(1, 1, 0)
        Dim pnt4 As New XYZ(0, 1, 0)
        Dim pnt5 As New XYZ(0, 0, 1)

        Dim arrarr1 As New CurveArrArray()
        Dim arr1 As New CurveArray()
        arr1.Append(Line.CreateBound(pnt1, pnt2))
        arr1.Append(Line.CreateBound(pnt2, pnt3))
        arr1.Append(Line.CreateBound(pnt3, pnt4))
        arr1.Append(Line.CreateBound(pnt4, pnt1))
        arrarr1.Append(arr1)

        Dim pnt6 As New XYZ(0.5, 0, 0)
        Dim pnt7 As New XYZ(1, 0.5, 0)
        Dim pnt8 As New XYZ(0.5, 1, 0)
        Dim pnt9 As New XYZ(0, 0.5, 0)
        Dim arrarr2 As New CurveArrArray()
        Dim arr2 As New CurveArray()
        arr2.Append(Line.CreateBound(pnt6, pnt7))
        arr2.Append(Line.CreateBound(pnt7, pnt8))
        arr2.Append(Line.CreateBound(pnt8, pnt9))
        arr2.Append(Line.CreateBound(pnt9, pnt6))
        arrarr2.Append(arr2)

        Dim bottomProfile As SweepProfile = document.Application.Create.NewCurveLoopsProfile(arrarr1)
        Dim topProfile As SweepProfile = document.Application.Create.NewCurveLoopsProfile(arrarr2)

        Dim pnt10 As New XYZ(5, 0, 0)
        Dim pnt11 As New XYZ(0, 20, 0)
        Dim curve As Curve = Line.CreateBound(pnt10, pnt11)

        ' here create rectangular swept blend
        newSweptBlend = document.FamilyCreate.NewSweptBlend(True, curve, sketchPlane, bottomProfile, topProfile)
        If newSweptBlend IsNot Nothing Then
            ' move to proper place
            Dim transPoint1 As New XYZ(11, 32, 0)
            ElementTransformUtils.MoveElement(document, newSweptBlend.Id, transPoint1)
        Else
            Throw New Exception("Failed to create new SweptBlend.")
        End If
    Else
        Throw New Exception("Please open a Family document before invoking this command.")
    End If
    Return newSweptBlend
End Function

Exceptions

Exception Condition
Autodesk.Revit.Exceptions ArgumentNullException Thrown when the input arguments-path/bottomProfile/topProfile-are a null reference ( Nothing in Visual Basic) .
Autodesk.Revit.Exceptions ArgumentException Thrown when the input argument-bottomProfile/topProfile-is a curve based profile and the profile is a null reference ( Nothing in Visual Basic) .
Autodesk.Revit.Exceptions ArgumentException Thrown when the input argument-bottomProfile/topProfile-is a curve based profile and the profile contains a null reference ( Nothing in Visual Basic) or more than one curve loops.
Autodesk.Revit.Exceptions ArgumentException Thrown when the input argument-bottomProfile/topProfile-is a family symbol based profile and the family symbol profile is a null reference ( Nothing in Visual Basic) .
Autodesk.Revit.Exceptions InvalidOperationException Thrown when creation is attempted in Conceptual Mass, 2D, or other family where swept blends cannot be created.
Autodesk.Revit.Exceptions InvalidOperationException Thrown when the creation failed.

See Also