Adds a new sweep form to the family document, using a path of curve elements.
Namespace: Autodesk.Revit.Creation
Assembly: RevitAPI (in RevitAPI.dll) Version: 18.0.0.0 (18.2.0.0)
Syntax
Parameters
- isSolid
- Type: System..::..Boolean
Indicates if the Sweep is Solid or Void.
- path
- Type: Autodesk.Revit.DB..::..CurveArray
The path of the sweep. The path should be 2D, where all input curves lie in one plane, and the curves are 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 nullNothingnullptra null reference (Nothing in Visual Basic) for 3D paths or
for 2D paths where the path should not reference an existing face.
- profile
- Type: Autodesk.Revit.DB..::..SweepProfile
The profile of the newly created Sweep. This may contain
more than one curve loop or a profile family. The profile must lie in the XY plane, and it will be
transformed to the profile plane automatically. Each loop must be a fully closed curve loop and the loops
must not intersect.
The loop can be a unbound circle or ellipse, but its geometry will be split in two in
order to satisfy requirements for sketches used in extrusions.
- profileLocationCurveIndex
- Type: System..::..Int32
The index of the path curves. The curve upon which the profile
plane will be determined.
- profilePlaneLocation
- Type: Autodesk.Revit.DB..::..ProfilePlaneLocation
The location on the profileLocationCurve where the profile
plane will be determined.
Return Value
If creation was successful the new Sweep is returned,
otherwise an exception with failure information will be thrown.
Remarks
Examples
CopyC#
private Sweep CreateSweep(Autodesk.Revit.DB.Document document, SketchPlane sketchPlane)
{
Sweep sweep = null;
if (true == document.IsFamilyDocument)
{
CurveArrArray arrarr = new CurveArrArray();
CurveArray arr = new CurveArray();
XYZ pnt1 = new XYZ(0, 0, 0);
XYZ pnt2 = new XYZ(2, 0, 0);
XYZ pnt3 = new XYZ(1, 1, 0);
arr.Append(Arc.Create(pnt2, 1.0d, 0.0d, 180.0d, XYZ.BasisX, XYZ.BasisY));
arr.Append(Arc.Create(pnt1, pnt3, pnt2));
arrarr.Append(arr);
SweepProfile profile = document.Application.Create.NewCurveLoopsProfile(arrarr);
XYZ pnt4 = new XYZ(10, 0, 0);
XYZ pnt5 = new XYZ(0, 10, 0);
Curve curve = Line.CreateBound(pnt4, pnt5);
CurveArray curves = new CurveArray();
curves.Append(curve);
sweep = document.FamilyCreate.NewSweep(true, curves, sketchPlane, profile, 0, ProfilePlaneLocation.Start);
if (null != sweep)
{
XYZ transPoint1 = new XYZ(11, 0, 0);
ElementTransformUtils.MoveElement(document, sweep.Id, transPoint1);
}
else
{
throw new Exception("Failed to create a new Sweep.");
}
}
else
{
throw new Exception("Please open a Family document before invoking this command.");
}
return sweep;
}
CopyVB.NET
Private Function CreateSweep(document As Autodesk.Revit.DB.Document, sketchPlane As SketchPlane) As Sweep
Dim sweep As Sweep = Nothing
If True = document.IsFamilyDocument Then
Dim arrarr As New CurveArrArray()
Dim arr As New CurveArray()
Dim pnt1 As New XYZ(0, 0, 0)
Dim pnt2 As New XYZ(2, 0, 0)
Dim pnt3 As New XYZ(1, 1, 0)
arr.Append(Arc.Create(pnt2, 1.0, 0.0, 180.0, XYZ.BasisX, XYZ.BasisY))
arr.Append(Arc.Create(pnt1, pnt3, pnt2))
arrarr.Append(arr)
Dim profile As SweepProfile = document.Application.Create.NewCurveLoopsProfile(arrarr)
Dim pnt4 As New XYZ(10, 0, 0)
Dim pnt5 As New XYZ(0, 10, 0)
Dim curve As Curve = Line.CreateBound(pnt4, pnt5)
Dim curves As New CurveArray()
curves.Append(curve)
sweep = document.FamilyCreate.NewSweep(True, curves, sketchPlane, profile, 0, ProfilePlaneLocation.Start)
If sweep IsNot Nothing Then
Dim transPoint1 As New XYZ(11, 0, 0)
ElementTransformUtils.MoveElement(document, sweep.Id, transPoint1)
Else
Throw New Exception("Failed to create a new Sweep.")
End If
Else
Throw New Exception("Please open a Family document before invoking this command.")
End If
Return sweep
End Function
Exceptions
See Also