There are two common mistakes you could make when creating a sweep using API. First, please make sure to create a sketch plane in which the sweep path is on the plane. The second, you can choose an arc for lines for the sweep path. You can not mix them together.
Here is the simple sample code creating a sweep with a circular profile and arced sweep path. You can uncomment the code for multiple lines sweep path instead of the arced path.
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
Transaction transaction = new Transaction(doc);
transaction.Start("Create a sweep");
// Sketch plane is important and must match the curves below.
// Here we use a sketch plane whose normal is X.
Plane geometryPlane =
SketchPlane sketchPlane =
CurveArrArray arrarr = new CurveArrArray();
CurveArray arr = new CurveArray();
// the units of the new arc angles are radians.
// Creating a profile of a circle
new XYZ(), 1.0, 0.0, 2 * Math.PI, XYZ.BasisX, XYZ.BasisY));
SweepProfile profile = doc.Application.
// Two lines which proceed in the YZ plane defined by the sketch plane: OK.
// If the second line were to go out of the sketch plane this would fail.
CurveArray curves = new CurveArray();
// Comment out either the arc or the lines, can't use both together
// NewLineBound(XYZ.Zero, new XYZ(0, 0, 10.0)));
// NewLineBound(new XYZ(0, 0, 10.0), new XYZ(0, 10.0, 10.0)));
// Arc must lie in the sketch plane. Again, X doesn't change, and the arc is only in YZ.
//// Create a new arc using two ends and a point on the curve
XYZ end0 = new XYZ(0, 0, 0); // start point of the arc
double radius = 10.0;
XYZ end1 = new XYZ(0, radius * (1.0 - Math.Sin(Math.PI / 6.0)),
radius * Math.Cos(Math.PI / 6.0)); // end point of the arc
XYZ pointOnCurve = new XYZ(0, radius * (1.0 - Math.Sin(Math.PI / 3.0)),
radius * Math.Cos(Math.PI / 3.0)); // point along arc
Arc arc = app.Create.NewArc(end0, end1, pointOnCurve);
Sweep sweep = doc.FamilyCreate.NewSweep(true, curves, sketchPlane,
profile, 0, ProfilePlaneLocation.Start);