Message 1 of 5
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I want to create a sweep in a family document with an arbitrary profile base on input.
However, I have receiving inconsistent result: sometime it succeeds, sometime it fails.
I don't know why since the profiles I tried to create are very simple as you can see below.
The error I received can vary from time to time if I change the values of the arcs and lines
but not the general shapes.
What are the causes for the problem and how to fix it?
However, I have receiving inconsistent result: sometime it succeeds, sometime it fails.
I don't know why since the profiles I tried to create are very simple as you can see below.
The error I received can vary from time to time if I change the values of the arcs and lines
but not the general shapes.
What are the causes for the problem and how to fix it?
private CurveArray CreatecustomCoverProfile(double offset) { // the following code worked // Arc arc1 = Arc.Create(new XYZ(0, 0, 0), 5, Math.PI / 2, Math.PI * 3 / 2, XYZ.BasisX, XYZ.BasisY); // Line line = Line.CreateBound(new XYZ(0, 5, 0), new XYZ(0, -5, 0)); // CurveArray curveArr = new CurveArray(); // curveArr.Append(arc); // curveArr.Append(line); // the following code failed XYZ center1 = new XYZ(0, 0, 0); XYZ center2 = new XYZ(10, 0, 0); Arc arc1 = Arc.Create(center1, 5, Math.PI / 2, Math.PI * 3 / 2, XYZ.BasisX, XYZ.BasisY); Arc arc2 = Arc.Create(center2, 5, Math.PI * 3 / 2, Math.PI * 5 / 2, XYZ.BasisX, XYZ.BasisY); Line line1 = Line.CreateBound(new XYZ(0, 5, 0), new XYZ(10, 5, 0)); Line line2 = Line.CreateBound(new XYZ(0, -5, 0), new XYZ(10, -5, 0)); CurveArray curveArr = new CurveArray(); curveArr.Append(arc1); curveArr.Append(line1); curveArr.Append(arc2); curveArr.Append(line2); return curveArr; } private bool CreateSweep(Document famDoc) { Family family = famDoc?.OwnerFamily; if (null == family) return false; Collection<XYZ> points = CreateCablePoints(); if (points.Count < 2) return false; using (Transaction trans = new Transaction(famDoc, "create cover")) { trans.Start(); // create profile CurveArrArray arArr = new CurveArrArray(); arArr.Append(CreatecustomCoverProfile(0)); SweepProfile profile = _rvApp.Create.NewCurveLoopsProfile(arArr); // create path // the path was created from a simple sine-like hermite spline with hardcode control points CurveArray path = CreatePath(points); // create sketch plane Plane plane = Plane.CreateByNormalAndOrigin(XYZ.BasisZ, XYZ.Zero); SketchPlane pathPlane = SketchPlane.Create(famDoc, plane); Sweep cover = famDoc.FamilyCreate.NewSweep(true, path, pathPlane, profile, 0, ProfilePlaneLocation.Start); trans.Commit(); } return true; }
Solved! Go to Solution.